VS 2012, StyleCop 4.7.44

Feb 17, 2013 at 12:26 AM
I'm getting the following error:
[msbuild] E:\hudson\buildIncludes\msbuild\StyleCop.msbuild(18,5): error : Failed to add file: E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs

The msbuild task at line 18 is as follows:
    <MSBuild.ExtensionPack.CodeQuality.StyleCop
      TaskAction="Scan"
      ShowOutput="true"
      ForceFullAnalysis="true"
      CacheResults="false"
      LogFile="$(ResultsDir)\StyleCopLog.txt"
      SettingsFile="E:\Program Files\StyleCop 4.7\Settings.StyleCop"
      SourceFiles="@(StyleCopFiles)"
    >
      <Output TaskParameter="Succeeded" PropertyName="AllPassed"/>
      <Output TaskParameter="ViolationCount" PropertyName="Violations"/>
      <Output TaskParameter="FailedFiles" ItemName="Failures"/>
    </MSBuild.ExtensionPack.CodeQuality.StyleCop>
I have verified that the path to the file is correct.
I have uninstalled and reinstalled both stylecop and the latest version of MsBuild extension pack.

Any assistance would be greatly appreciated.
Thanks -- Dan'l
Coordinator
Feb 18, 2013 at 12:03 AM
Nothing is jumping out. Can you attach a log using /v:diag
Feb 18, 2013 at 12:59 AM
wow, lots of information with that. Here it is:
(I left off the list of environment variables as there is a limit to what can be posted)
[msbuild] Building with tools version "2.0".
[msbuild] Target "StyleCop: (TargetId:2)" in project "E:\hudson\buildIncludes\msbuild\StyleCop.msbuild" (entry point):
[msbuild] Using "Message" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
[msbuild] Task "Message" (TaskId:2)
[msbuild] Task Parameter:Text=SourceDir=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs (TaskId:2)
[msbuild] SourceDir=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs (TaskId:2)
[msbuild] Done executing task "Message". (TaskId:2)
[msbuild] Using "CreateItem" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
[msbuild] Task "CreateItem" (TaskId:3)
[msbuild] Task Parameter:Include=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs (TaskId:3)
[msbuild] Done executing task "CreateItem". (TaskId:3)
[msbuild] Using "WriteLinesToFile" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
[msbuild] Task "WriteLinesToFile" (TaskId:4)
[msbuild] Task Parameter:File=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\TestResults\Debug/LindbergCorp.stylecop.results.xml (TaskId:4)
[msbuild] Task Parameter:Lines=<StyleCopViolations> (TaskId:4)
[msbuild] Done executing task "WriteLinesToFile". (TaskId:4)
[msbuild] Using "MSBuild.ExtensionPack.CodeQuality.StyleCop" task from assembly "C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.StyleCop.dll".
[msbuild] Task "MSBuild.ExtensionPack.CodeQuality.StyleCop" (TaskId:5)
[msbuild] Task Parameter:TaskAction=Scan (TaskId:5)
[msbuild] Task Parameter:ShowOutput=True (TaskId:5)
[msbuild] Task Parameter:ForceFullAnalysis=True (TaskId:5)
[msbuild] Task Parameter:CacheResults=False (TaskId:5)
[msbuild] Task Parameter:LogFile=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\TestResults\Debug\StyleCopLog.txt (TaskId:5)
[msbuild] Task Parameter:SettingsFile=E:\Program Files\StyleCop 4.7\Settings.StyleCop (TaskId:5)
[msbuild] Task Parameter:
[msbuild] SourceFiles=
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\LCS.master.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\DownloadFileInfo.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\FileDownloader.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\PhoneLocale.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\ResumeInfo.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\ResumeInfoController.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\App_Code\SessionIndex.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\App_Code\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Products\MyPrayers.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\Products\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Services\Business.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk**.cs
[msbuild] RecursiveDir=LindbergCorp\Services\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\UtilityPages\DownloadPage.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\UtilityPages\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\UtilityPages\LeaveReview.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\UtilityPages\
[msbuild] E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\UtilityPages\ResumePage.aspx.cs
[msbuild] OriginalItemSpec=E:\hudson\jobs\LindbergCorp.Website\workspace\trunk*
*.cs
[msbuild] RecursiveDir=LindbergCorp\UtilityPages\ (TaskId:5)
[msbuild] Performing StyleCop scan... (TaskId:5)
[msbuild] SourceFiles count is: 13 (TaskId:5)
[msbuild] Adding file: E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs (TaskId:5)
[msbuild] E:\hudson\buildIncludes\msbuild\StyleCop.msbuild(18,5): error : Failed to add file: E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs
[msbuild] Done executing task "MSBuild.ExtensionPack.CodeQuality.StyleCop" -- FAILED. (TaskId:5)
[msbuild] Done building target "StyleCop" in project "StyleCop.msbuild" -- FAILED.: (TargetId:2)
[msbuild] Done Building Project "E:\hudson\buildIncludes\msbuild\StyleCop.msbuild" (StyleCop target(s)) -- FAILED.
[msbuild] Deferred Messages
[msbuild]
[msbuild] Detailed Build Summary
[msbuild] ======================
[msbuild] (TaskId:0)
[msbuild]
[msbuild] ============================== Build Hierarchy (IDs represent configurations) =====================================================
[msbuild] Id : Exclusive Time Total Time Path (Targets)
[msbuild] ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
[msbuild] 0 : 0.328s 0.328s E:\hudson\buildIncludes\msbuild\StyleCop.msbuild (StyleCop) (TaskId:0)
[msbuild]
[msbuild] ============================== Node Utilization (IDs represent configurations) ====================================================
[msbuild] Timestamp: 1 Duration Cumulative
[msbuild] ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
[msbuild] 634967454371316921: 0 0.328s 0.328s ###### (TaskId:0)
[msbuild] -----------------------------------------------------------------------------------------------------------------------------------
[msbuild] Utilization: 100.0 Average Utilization: 100.0 (TaskId:0)
[msbuild]
[msbuild] Project Performance Summary:
[msbuild] 296 ms E:\hudson\buildIncludes\msbuild\StyleCop.msbuild 1 calls
[msbuild] 296 ms StyleCop 1 calls
[msbuild]
[msbuild] Target Performance Summary:
[msbuild] 265 ms StyleCop 1 calls
[msbuild]
[msbuild] Task Performance Summary:
[msbuild] 0 ms WriteLinesToFile 1 calls
[msbuild] 16 ms Message 1 calls
[msbuild] 47 ms CreateItem 1 calls
[msbuild] 140 ms MSBuild.ExtensionPack.CodeQuality.StyleCop 1 calls
[msbuild]
[msbuild] Build FAILED.
[msbuild]
[msbuild] "E:\hudson\buildIncludes\msbuild\StyleCop.msbuild" (StyleCop target) (1) ->
[msbuild] (StyleCop target) ->
[msbuild] E:\hudson\buildIncludes\msbuild\StyleCop.msbuild(18,5): error : Failed to add file: E:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs
[msbuild]
[msbuild] 0 Warning(s)
[msbuild] 1 Error(s)
[msbuild]
[msbuild] Time Elapsed 00:00:00.37

BUILD FAILED
Feb 18, 2013 at 1:05 AM
Also, there's nothing particularly interesting about the file it's complaining about. It passes StyleCop in the IDE. Here's the contents of that file:
//-----------------------------------------------------------------------
// <copyright file="Default.aspx.cs" company="Daniel Lindberg, Inc.">
// Copyright (C) 2008-2013 Daniel Lindberg, Inc. and/or one of its subsidiaries. All Rights Reserved.
// Use of this material is governed by a license agreement.
// This material contains confidential, proprietary and trade secret information of JHS 
// and is protected under United States and international copyright and other intellectual 
// property laws. Use, disclosure, reproduction, modification, distribution, or storage in 
// a retrieval system in any form or by any means is prohibited without the prior express 
// written permission of Daniel Lindberg, Inc.
// </copyright>
//-----------------------------------------------------------------------

namespace LindbergCorp.Website
{
    using System;
    using System.Web.UI;

    /// <summary>
    /// The home page for LindbergCorp's website.
    /// </summary>
    public partial class Default : Page
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}
Coordinator
Feb 18, 2013 at 4:29 AM
No repro this side

Building with tools version "2.0".
Target "GetWorkingSets: (TargetId:2)" in project "D:\a\AnIdea.proj" (entry point):
Using "MSBuild.ExtensionPack.CodeQuality.StyleCop" task from assembly "C:\Program Files (x86)\Style
Cop 4.7\MSBuild.ExtensionPack.StyleCop.dll".
Task "MSBuild.ExtensionPack.CodeQuality.StyleCop" (TaskId:2)
Task Parameter:TaskAction=Scan (TaskId:2)
Task Parameter:ShowOutput=True (TaskId:2)
Task Parameter:ForceFullAnalysis=True (TaskId:2)
Task Parameter:CacheResults=False (TaskId:2)
Task Parameter:LogFile=d:\hudson\StyleCopLog.txt (TaskId:2)
Task Parameter:SettingsFile=c:\Program Files (x86)\StyleCop 4.7\Settings.StyleCop (TaskId:2)
Task Parameter:SourceFiles=D:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Defau
lt.aspx.cs (TaskId:2)
Performing StyleCop scan... (TaskId:2)
SourceFiles count is: 1 (TaskId:2)
Adding file: D:\hudson\jobs\LindbergCorp.Website\workspace\trunk\LindbergCorp\Default.aspx.cs (Ta
skId:2)
Pass 1: Default.aspx.cs (TaskId:2)
Pass 2: Default.aspx.cs (TaskId:2)
No violations encountered (TaskId:2)
Done executing task "MSBuild.ExtensionPack.CodeQuality.StyleCop". (TaskId:2)


I wonder if it's an encoding issue? can you send me the actual file?

You could also try download hte code and step through the task. It would be nice to get a repro so I could determine if we need any more guard code.

Mike
Feb 18, 2013 at 11:21 AM
Edited Feb 18, 2013 at 11:25 AM
I'll try to get the code tonight.

I replied to the e-mail and attached the file. I don't know how to get the file to you from this web interface.
Dan'l
Feb 19, 2013 at 11:56 PM
I downloaded the code. I didn't see any unit tests for the StyleCop project. Can you give me some pointers on the best way to debug this?
Thanks -- Dan'l
Coordinator
Feb 20, 2013 at 12:08 AM
Open the Mainsolution.
Set Stylecop project as the startup project in the solution
Edit [yourdrive]\MSBuildExtensionPack\Solutions\Main\StyleCop\XmlSamples\StyleCop.proj to include your code.
Go to the properties of the Stylecop project.
On the debug tab, set startup program to C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe and set the commandline arguments as [yourdrive]\MSBuildExtensionPack\Solutions\Main\StyleCop\XmlSamples\StyleCop.proj

Set a breakpoint in the code and hit F5

I just realised i didnt test the file you sent me. let me try that too.
Feb 20, 2013 at 1:43 AM
Thanks. I'll dig into it a bit more tomorrow. Right now, it's looking for version 4.7.1000.0 of stylecop.dll Not sure which dll is looking for that, but the most recent version i have is 4.7.44.0. Running msbuild from the command-line, i get this error:

"E:\Downloads\MSBuild Extension Pack April 2012 (All Files)\msbuildextensionpack-82662\Solutions\Main\StyleCop\XmlSamples\StyleCop.proj" (default target) (1) ->
(Default target) ->
E:\Downloads\MSBuild Extension Pack April 2012 (All Files)\msbuildextensionpack-82662\Solutions\Main\StyleCop\XmlSamples\StyleCop.proj(13,5): error : FileNotFoundException: Could not load file or assembly 'StyleCop, Version=4.7.1000.0, Culture=neutral, PublicKeyToken=f904653c63bc2738' or one of its dependencies. The system cannot find the file specified.\r
E:\Downloads\MSBuild Extension Pack April 2012 (All Files)\msbuildextensionpack-82662\Solutions\Main\StyleCop\XmlSamples\StyleCop.proj(13,5): error :
Feb 21, 2013 at 12:40 AM
Apparently it needs msbuild v3.5, which is no longer installed on my computers. StyleCop.dll is referencing
.assembly extern 'Microsoft.Build.Utilities.v3.5'
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 3:5:0:0
}

I guess i could re-install VS 2010. Have you had any luck reproducing the issue?
Dan'l
Coordinator
Feb 21, 2013 at 1:00 AM
not yet sorry. can you raise that 3.5 issue on the stylecop page.
Feb 21, 2013 at 1:21 AM
Feb 23, 2013 at 5:34 PM
I am able to reproduce this from the code i downloaded. The call to console.Core.Environment.AddSourceCode is returning false.
Feb 23, 2013 at 5:45 PM
I am able to reproduce this from the code i downloaded. The call to console.Core.Environment.AddSourceCode is returning false.
Mar 1, 2013 at 8:18 PM
Have you been able to reproduce this?
Dan'l
Coordinator
Mar 4, 2013 at 7:47 AM
Hi Dan

That seems to be a stylecop issue then. I'll try get a response from that team.

Mike
Coordinator
Mar 12, 2013 at 3:23 PM
Marked as answer by mikeFourie on 10/9/2013 at 3:28 PM
Mar 12, 2013 at 3:36 PM
Thanks. I'll give that a try tonight.
Dan'l

Mar 13, 2013 at 1:05 AM
I installed .net 3.5 and the problem remains.
Mar 13, 2013 at 1:07 AM
I should also note that i've been successful in an environment where VS 2010 and VS 2012 are both installed. The environment i'm having difficulty with is one where only VS 2012 is installed.
Hopefully someone has some other ideas for a workaround.

Thanks -- Dan'l