MsbuildSonar Runner +Fxcop - No fxcop issues are posted to server.SonarDashBoard shows 0 technical debt - msbuild

I am using Sonarqube 5.1 with MsBuildSonarRunner for my c#.net project analysis. Sonarqube 5.1 has come with C# 4.1 plugin, Recently I upgraded to 4.2. I have created a quality profile with ONLY Fxcop rules. I have followed the steps mentioned in Sonar site for analysis.
In analysis, I see that FXcop rule violations are captured. But when I browse to SonarDash board, It shows technical debt as 0 and issues as 0. I have reviewed my steps many times and I don't see any mistakes from my side. What could be the reason why Issues are not posted to server.
Here is my Build command log. I see clearly FXCOP rules are applied and violations are printed on console during build phase.
===========================================================
Microsoft (R) Build Engine version 12.0.21005.1
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/19/2015 12:20:14 PM.
Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
Polindrome -> D:\Sqp\Polindrome\Polindrome\bin\Debug\Polindrome.exe
OverrideCodeAnalysisProperties:
Running FxCop analysis using the SonarQube ruleset. Ruleset: D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset
RunCodeAnalysis:
Running Code Analysis...
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe /outputCulture:1033 /out:"bin\Debug\Polindrome.exe.CodeAnalysisLog.xml" /file:"bin\Debug\Polindrome.exe" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.Xml.Linq.dll" /directory:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1" /ruleSet:"=D:\Sqp\Polindrome\Polindrome\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset" /rulesetdirectory:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\\Rule Sets" /rule:"-C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\\Rules" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120
MSBUILD : **warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it.** [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]
Code Analysis Complete -- 0 error(s), 1 warning(s)
SetStyleCopAnalysisSettings:
Setting 'sonar.stylecop.projectFilePath' to 'D:\Sqp\Polindrome\Polindrome\Polindrome.csproj'
WriteSonarQubeProjectData:
Directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589" doesn't exist. Skipping.
Creating directory "D:\Sqp\Polindrome\Polindrome\.sonarqube\out\\Polindrome__AnyCPU_Debug_635803356164104589".
Done Building Project "D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default targets).
Build succeeded.
"D:\Sqp\Polindrome\Polindrome\Polindrome.csproj" (default target) (1) ->
(RunCodeAnalysis target) ->
MSBUILD : warning CA1823: Microsoft.Performance : It appears that field 'Program.AccountList' is never used or is only ever assigned to. Use this field or remove it. [D:\Sqp\Polindrome\Polindrome\Polindrome.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.82

FxCop analyzes assemblies, and relies on *.pdb files to map issues back to locations within the source code (i.e. to specific *.cs files at specific lines).
The issue reported by CA1823 seems to be on a field, which due to limitations of the *.pdb format are not being mapped back to source code. These issues are ignored during the import of FxCop results into SonarQube. You can verify that by manually opening the FxCop report (whose path you'll find in .sonarqube\out*\ProjectInfo.xml).
There is already a ticket to improve this in a future version of the C# plugin: https://jira.sonarsource.com/browse/SONARFXCOP-32
Update November 18th 2015
After many comments on this answer (see below), the root cause of the issue was finally found: The SQL Server collation must be case-sensitive (CS) and accent-sensitive (AS).
SonarQube 5.3 is expected to fail faster when this is not the case, to avoid these kind of strange problems: https://jira.sonarsource.com/browse/SONAR-6884

Related

How to define where msbuild looks for packages?

I'm trying to build a solution from command line. This involves 3 steps:
nuget install
nuget restore
msbuild
I am using a NuGet.Config files that specifies where the nuget packages are cached to, and also where the restored packages are added.
The command nuget restore does not work, nor does it provide a helpful error message other than 'the solution can't be built'. Another answer on StackOverflow helpfully recommended to run the msbuild command and see what the error is.
It would seem that files installed via nuget are not found during msbuild (or apparently nuget restore). This is the log from msbuild for every single assembly other than what is found in GAC:
Primary reference "NTRPRS.NLog.Slack".
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "NTRPRS.NLog.Slack". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\Avesta\Services\Dashboard\src\Avesta.DashboardService.csproj]
For SearchPath "{HintPathFromItem}".
Considered "..\..\..\..\AppData\Roaming\NuGet\packages\NTRPRS.NLog.Slack.5.0.4\lib\net45\NTRPRS.NLog.Slack.dll", but it didn't exist.
For SearchPath "{TargetFrameworkDirectory}".
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\NTRPRS.NLog.Slack.exe", but it didn't exist.
For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx}".
Considered AssemblyFoldersEx locations.
For SearchPath "{AssemblyFolders}".
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\130\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\130\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\130\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files\IIS\Microsoft Web Deploy V3\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\NTRPRS.NLog.Slack.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\140\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\140\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\140\NTRPRS.NLog.Slack.exe", but it didn't exist.
For SearchPath "{GAC}".
Considered "NTRPRS.NLog.Slack", which was not found in the GAC.
For SearchPath "{RawFileName}".
Considered treating "NTRPRS.NLog.Slack" as a file name, but it didn't exist.
For SearchPath "bin\Debug\".
Considered "bin\Debug\NTRPRS.NLog.Slack.winmd", but it didn't exist.
Considered "bin\Debug\NTRPRS.NLog.Slack.dll", but it didn't exist.
Considered "bin\Debug\NTRPRS.NLog.Slack.exe", but it didn't exist.
How can I specify to msbuild where assemblies installed by nuget are? Also.... why is nuget restore failing? The message I get from nuget restore is:
C:\<path>\src>nuget restore
Error parsing solution file at C:\<path>\src\<name>.sln: Exception has been thrown by the target of an invocation.
The project file could not be loaded. Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The system cannot find the file specified. C:\<path>\src\<name>.sln
using:
MSBuild auto-detection: using msbuild version '15.7.177.53362' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
As far as I can tell, the nuget error output is completely nonsensical. The absolute path C:\<path>\src\<name>.sln absolutely does exist.
This is a problem that only surfaced after 15.7.0 of Visual Studio / MSBuild.
NuGet already has an open issue for this problem: https://github.com/NuGet/Home/issues/6918
The current workaround is to install .NET 4.7.1 until the problem is fixed, because that will install the missing library in the Global Assembly Cache.

MSBuild fails with an error in the "AL" task with error code AL1019

We are currently having problems while compiling a solution with MSBuild. The build fails randomly on the resource linking step inside the task "AL" which executes the "AL.exe" linker.
ALINK : error AL1019: Metadata failure while creating assembly -- The volume for a file has been externally altered so that the opened file is no longer valid.
The build log shows the following execution flow.
4>Target "GenerateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\source\MyProject.csproj" (target "CreateSatelliteAssemblies" depends on it):
4>Building target "GenerateSatelliteAssemblies" completely.
4>Output file "obj\Debug\de\MyProject.dll" does not exist.
4>Task "MakeDir"
4>Done executing task "MakeDir".
4>Task "AL"
4> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\AL.exe /culture:de /out:obj\Debug\de\MyProject.resources.dll /template:obj\Debug\MyProject.dll /embed:obj\Debug\MyProject.SomeResource.de.resources
4> Microsoft (R) Assembly Linker version 14.0.0081.0
4> Copyright (C) Microsoft Corporation. All rights reserved.
4>
4>Done executing task "AL".
4>Done building target "GenerateSatelliteAssemblies" in project "MyProject.csproj".
4>Target "GenerateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\source\MyProject.csproj" (target "CreateSatelliteAssemblies" depends on it):
4>Building target "GenerateSatelliteAssemblies" completely.
4>Output file "obj\Debug\en\MyProject.resources.dll" does not exist.
4>Task "MakeDir"
4>Done executing task "MakeDir".
4>Task "AL"
4> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\AL.exe /culture:en /out:obj\Debug\en\MyProject.resources.dll /template:obj\Debug\MyProject.dll /embed:obj\Debug\MyProject.SomeResource.en.resources
4> Microsoft (R) Assembly Linker version 14.0.0081.0
4> Copyright (C) Microsoft Corporation. All rights reserved.
4>
4>ALINK : error AL1019: Metadata failure while creating assembly -- The volume for a file has been externally altered so that the opened file is no longer valid.
4> The command exited with code 1.
4>Done executing task "AL" -- FAILED.
4>Done building target "GenerateSatelliteAssemblies" in project "MyProject.csproj" -- FAILED.
To me it is completely unclear what is meant by the error code AL1019. The MSDN error code listing didn't help either.

Continuous Integration with .Net Core App and Database Project (VS2017)

I have a .net Core app in VS2017 that also has a Database Project in the solution as well.
I want to set up continuous integration within Visual Studio Team Services to Build and Publish both the app and the database project. I have been able to get either the database project or app in the Publish Artifacts, but can't get them both at the same time. I am assuming I have set up my paths up wrong, but I have not had an luck with any of the combinations I have tried and there is very little documentation that I can find on having both an .net core app and a database project build and deploy together. How do I build and publish both the .net core app and the database project together in VSTS?
Below is the current set up I have in VSTS for the Build. I currently was trying to put the database project in one folder ($(build.artifactstagingdirectory)) and the app in another folder since resulted in
List of current steps
Below is the output from the current setup as seen in the image above
Starting: Build
******************************************************************************
Task : .NET Core
Description : Build, test and publish using dotnet core command-line.
Version : 1.0.2
Author : Microsoft Corporation
"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\DatabaseDeploymentTest.web\DatabaseDeploymentTest.web.csproj --configuration release
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
DatabaseDeploymentTest.web -> d:\a\1\s\DatabaseDeploymentTest.web\bin\release\netcoreapp1.1\DatabaseDeploymentTest.web.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:07.50
Finishing: Build
Starting: Build solution **/*.sln
******************************************************************************
Task : MSBuild
Description : Build with MSBuild
Version : 1.120.0
Author : Microsoft Corporation
"D:\a_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.120.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "d:\a\1\s\DatabaseDeploymentTest.sln" /nologo /nr:false /dl:CentralLogger,"D:\a_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=d:\a\1\s"*ForwardingLogger,"D:\a_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /t:build /p:CmdLineInMemoryStorage=True /p:_MSDeployUserAgent="VSTS_8786b412-4ab0-4ae3-aa96-af0394363b64_build_32_835"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/7/2017 6:40:49 PM.
Project "d:\a\1\s\DatabaseDeploymentTest.sln" on node 1 (build target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "d:\a\1\s\DatabaseDeploymentTest.sln" (1) is building "d:\a\1\s\DatabaseDeploymentTest\DatabaseDeploymentTest.sqlproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Debug\".
Creating directory "obj\Debug\".
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\mscorlib.dll" /debug+ /debug:full /optimize- /out:obj\Debug\DatabaseDeploymentTest.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /warnaserror- /utf8output "d:\a_temp.NETFramework,Version=v4.5.2.SqlClrAttributes.cs"
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn
SqlBuild:
Creating a model to represent the project...
Loading project references...
Loading project files...
Building the project model and resolving object interdependencies...
Validating the project model...
Writing model to d:\a\1\s\DatabaseDeploymentTest\obj\Debug\Model.xml...
DatabaseDeploymentTest\dbo\Stored Procedures\LoadEmployees.sql(1,1): Warning SQL71558: The object reference [dbo].[Employees].[HKSEmployeeId] differs only by case from the object definition [dbo].[Employees].[HKSEmployeeID].
d:\a\1\s\DatabaseDeploymentTest\dbo\Stored Procedures\LoadEmployees.sql(1,1,1,1): Build warning SQL71558: The object reference [dbo].[Employees].[HKSEmployeeId] differs only by case from the object definition [dbo].[Employees].[HKSEmployeeID]. [d:\a\1\s\DatabaseDeploymentTest\DatabaseDeploymentTest.sqlproj]
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\DatabaseDeploymentTest.dll" to "bin\Debug\DatabaseDeploymentTest.dll".
DatabaseDeploymentTest -> d:\a\1\s\DatabaseDeploymentTest\bin\Debug\DatabaseDeploymentTest.dll
Copying file from "obj\Debug\DatabaseDeploymentTest.pdb" to "bin\Debug\DatabaseDeploymentTest.pdb".
SqlPrepareForRun:
DatabaseDeploymentTest -> d:\a\1\s\DatabaseDeploymentTest\bin\Debug\DatabaseDeploymentTest.dacpac
Done Building Project "d:\a\1\s\DatabaseDeploymentTest\DatabaseDeploymentTest.sqlproj" (default targets).
Project "d:\a\1\s\DatabaseDeploymentTest.sln" (1) is building "d:\a\1\s\DatabaseDeploymentTest.web\DatabaseDeploymentTest.web.csproj" (3) on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Debug\netcoreapp1.1\".
Creating directory "obj\Debug\netcoreapp1.1\".
PreComputeCompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\tsc.exe --noEmitOnError --listEmittedFiles
CompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\tsc.exe --noEmitOnError --listEmittedFiles
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;DEBUG;NETCOREAPP1_1 /reference:C:\Users\buildguest.nuget\packages\microsoft.applicationinsights.aspnetcore\2.0.0\lib\netstandard1.6\Microsoft.ApplicationInsights.AspNetCore.dll /reference:C:\Users\buildguest.nuget\packages\microsoft.applicationinsights\2.2.0\lib\netstandard1.5\Microsoft.ApplicationInsights.dll /reference:C:\Users\buildguest.nuget\packages\microsoft.aspnetcore.antiforgery\1.1.1\lib\netstandard1.3\Microsoft.AspNetCore.Antiforgery.dll /reference:C:\Users\buildguest.nuget\packages\microsoft.aspnetcore.authorization\1.1.1\lib\netstandard1.3\Microsoft.AspNetCore.Authorization.dll /reference:C:\Users\buildguest.nuget\packages\microsoft.aspnetcore.cors\1.1.1\lib\netstandard1.3\Microsoft.AspNetCore.Cors.dll /reference:C:\Users\buildguest.nuget\packages\microsoft.aspnetcore.cryptography.internal\1....
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn
GetTypeScriptCopyToOutputDirectoryItems:
Adding items with BuildAction=TypeScriptCompile to the same collections that will be populated (with items of other BuildActions) by the GetCopyToOutputDirectoryItems target
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\netcoreapp1.1\DatabaseDeploymentTest.web.dll" to "bin\Debug\netcoreapp1.1\DatabaseDeploymentTest.web.dll".
DatabaseDeploymentTest.web -> d:\a\1\s\DatabaseDeploymentTest.web\bin\Debug\netcoreapp1.1\DatabaseDeploymentTest.web.dll
Copying file from "obj\Debug\netcoreapp1.1\DatabaseDeploymentTest.web.pdb" to "bin\Debug\netcoreapp1.1\DatabaseDeploymentTest.web.pdb".
Done Building Project "d:\a\1\s\DatabaseDeploymentTest.web\DatabaseDeploymentTest.web.csproj" (default targets).
Done Building Project "d:\a\1\s\DatabaseDeploymentTest.sln" (build target(s)).
Build succeeded.
"d:\a\1\s\DatabaseDeploymentTest.sln" (build target) (1) ->
"d:\a\1\s\DatabaseDeploymentTest\DatabaseDeploymentTest.sqlproj" (default target) (2) ->
(SqlBuild target) ->
d:\a\1\s\DatabaseDeploymentTest\dbo\Stored Procedures\LoadEmployees.sql(1,1,1,1): Build warning SQL71558: The object reference [dbo].[Employees].[HKSEmployeeId] differs only by case from the object definition [dbo].[Employees].[HKSEmployeeID]. [d:\a\1\s\DatabaseDeploymentTest\DatabaseDeploymentTest.sqlproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:12.94
Finishing: Build solution **/*.sln
Starting: Copy Files to: $(build.artifactstagingdirectory)
******************************************************************************
Task : Copy Files
Description : Copy files from source folder to target folder using match patterns (The match patterns will only match file paths, not folder paths)
Version : 2.117.0
Author : Microsoft Corporation
found 0 files
Finishing: Copy Files to: $(build.artifactstagingdirectory)
Starting: Publish
******************************************************************************
Task : .NET Core
Description : Build, test and publish using dotnet core command-line.
Version : 1.0.2
Author : Microsoft Corporation
"C:\Program Files\dotnet\dotnet.exe" publish d:\a\1\s\DatabaseDeploymentTest.web\DatabaseDeploymentTest.web.csproj --configuration release --output d:\a\1\a\DatabaseDeploymentTest.web
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
DatabaseDeploymentTest.web -> d:\a\1\s\DatabaseDeploymentTest.web\bin\release\netcoreapp1.1\DatabaseDeploymentTest.web.dll
Finishing: Publish
Starting: Publish Artifact
******************************************************************************
Task : Publish Build Artifacts
Description : Publish Build artifacts to the server or a file share
Version : 1.120.1
Author : Microsoft Corporation
Async Command Start: Upload Artifact
Uploading 1 files
File upload succeed.
Upload 'd:\a\1\a' to file container: '#/677588/DatabaseDeploymentTest'
Associated artifact 724 with build 835
Async Command End: Upload Artifact
Finishing: Publish Artifact
Specify $(build.sourcesdirectory) in Source Folder and **\*.dacpac in Contents of Copy files task.

FAKE MSBuild step can't resolve references

I have a FAKE build script which will run perfectly fine if I build the project once using VisualStudio, but if I try and do a fresh build then it throws errors saying it can't find the namespace of both a number of nuget packages and my dependant visual studio projects.
I'm using FAKE's MSBuildRelease and passing in the .sln file like so:
Target "BuildWindowsProject" (fun _ ->
MSBuildRelease
""
"Build"
[ "./Source/My.Project.sln" ]
|> Log "Windows-Build: "
)
It's giving out a number of errors such as below, but these include both projects within the solution and external nuget packages.
The type or namespace name 'Caliburn' could not be found (are you missing a using directive or an assembly reference?)
I did notice that back in 2011 this was posted - MSBuild cannot find a reference but it's quite old and I can't find any more recent occurrences of the issue online.
It works just fine if I do a visual studio build first and then run my build script but this doesn't solve the problem for a build server. What am I doing wrong?
You have to perform deep diagnostic by yourself, because the question under consideration requires the source code to be published here. It also can depend on the environment where the script is running, in order to get you the right answer.
You have an option on MSBuild utility to pass verbosity level of output. Use the following switch value to get detailed information about how the references are resolved during the build:
msbuild ./Source/My.Project.sln /t:Build /v:d
Using this command, you can navigate to the steps called ResolveAssemblyReference and ResolveProjectReference. You can see all the paths, where it will search for assemblies, and if it is succeded:
4> Primary reference "System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
4> Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Remoting.dll".
4> Reference found at search path location "{TargetFrameworkDirectory}".
4> For SearchPath "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64".
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib\amd64\System.Runtime.Remoting.exe", but it didn't exist.
4> For SearchPath "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64".
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.winmd", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.dll", but it didn't exist.
4> Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\System.Runtime.Remoting.exe", but it didn't exist.
4> For SearchPath "{TargetFrameworkDirectory}".
4> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Remoting.winmd", but it didn't exist.
4> This reference is not "CopyLocal" because it's a prerequisite file.
4> The ImageRuntimeVersion for this reference is "v4.0.30319".
You also can examine which references were passed to the compiler if you look at commandline, which was generated by MSBuild and find out if there is a reference you are required in.
For cl:
4> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe
...
/AI"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
...
/FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll"
/FUE:\YourProj\bin\Debug\Your.Proj.dll
/FU"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Configuration.dll"
...
/errorReport:prompt
YourSourceCodeFiles.cpp
/clr:nostdlib
For csc:
2> C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe
...
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll"
/reference:E:\svn\PRM\trunk\PRM30\bin\Debug\Prm.Base.dll
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Configuration.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Core.dll"
...
(most of parameters were omited for simplicity)

TeamCity won't publish project using MsDeploy

I have msbuild command to publish my project (WCF Service Application) that looks as follow:
msbuild FooBar.Service.csproj /p:DeployOnBuild=true;
DeployTarget=MsDeployPublish;
MSDeployServiceUrl=http://server.pl/MSDeployAgentService;
DeployIisAppPath="Foobar";
MSDeployPublishMethod=RemoteAgent;
UserName=Joe;
password=secret;
and this works from VS Command Prompt, all is published without any errors. Please note, that I'm not specyfing any Target.
But I want to create my Deployment Project using TeamCity (7.1.5). I have done simple project, and Configuration with one Build Step:
The problem is that, when I'm running this Task, msbuild compiles my site but without publishing it to remote server. Below is the build log:
[16:13:16]Checking for changes
[16:13:18]Publishing internal artifacts
[16:13:18][Publishing internal artifacts] Sending build.start.properties.gz file
[16:13:18]Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[16:13:18]Checkout directory: C:\TeamCity\buildAgent\work\2eecf7b45f277a61
[16:13:18]Repository sources transferred
[16:13:18]Updating sources: server side checkout
[16:13:18]Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\2eecf7b45f277a61 /msbuildPath:C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
[16:13:18]in directory: C:\TeamCity\buildAgent\work\2eecf7b45f277a61
[16:13:20]Foobar.csproj.teamcity: Build target: Build
[16:13:20][Foobar.csproj.teamcity] CoreCompile
[16:13:20][CoreCompile] Csc
[16:13:20][Csc] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Configuration.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.EnterpriseServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.ApplicationServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.DynamicData.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.Entity.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.Extensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.Services.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /debug+ /debug:full /optimize- /out:obj\Debug\Foobar.dll /subsystemversion:6.00 /target:library /utf8output Service1.svc.cs IService1.cs Properties\AssemblyInfo.cs "C:\TeamCity\buildAgent\temp\buildTmp\.NETFramework,Version=v4.5.AssemblyAttributes.cs"
[16:13:20][Foobar.csproj.teamcity] CopyFilesToOutputDirectory
[16:13:20][CopyFilesToOutputDirectory] Copy
[16:13:20][Copy] Copying file from "obj\Debug\Foobar.dll" to "bin\Foobar.dll".
[16:13:20][CopyFilesToOutputDirectory] Foobar.csproj -> C:\TeamCity\buildAgent\work\2eecf7b45f277a61\bin\Foobar.dll
[16:13:20][CopyFilesToOutputDirectory] Copy
[16:13:20][Copy] Copying file from "obj\Debug\Foobar.pdb" to "bin\Foobar.pdb".
[16:13:19]Targets was not defined in the build configuration.
[16:13:19]MSBuild command line parameters contain "/property:" or "/p:". It is recommended to define System Property on Build Parameters instead.
[16:13:21]Process exited with code 0
[16:13:21]Publishing internal artifacts
[16:13:21][Publishing internal artifacts] Sending build.finish.properties.gz file
[16:13:21]Publishing artifacts
[16:13:21][Publishing artifacts] Collecting files to publish: [C:\TeamCity\buildAgent\work\2eecf7b45f277a61]
[16:13:21][Publishing artifacts] Sending
[16:13:21]Build finished
I haven't looked through this in depth but noticed that in your command-line example you're specifying DeployIisAppPath, but looks like you're using DeployAppPath in your TeamCity script, which will just be ignored by MSBuild, I think.
Having the same issue for visual studio 2013 projects. another configuration just building and deploying fine
It's worth noticing that you're getting the following warning:
MSBuild command line parameters contain "/property:" or "/p:".
It is recommended to define System Property on Build Parameters instead.
What it's saying is that the best practice for passing numerous parameters to command-line based executions is to define parameters as System Properties rather than explicitly concatenate them in one long string.
As a suggestion for refactoring, I'd recommend you to define the parameters that you're passing through /p: prefix as System Properties (this can be done on Build Parameters section of your Build Configuration). In this case they will be passed to executions behind the scenes and will help you to avoid duplication, get easily maintainable and so on. It will also make the parameters list more clear and help you to find out if there is something wrong with the parameters you're passing to MSBuild that may cause the issue.