When I run Cruise Control .Net, msbuild does not behave the same as when I run directly from command line on the same machine with same exact options. What started me looking into this is that WebCompiler was not running when ccnet ran msbuild against my solution. However, when I run from command line WebCompiler builds runs just fine. I ran with the /verbosity:diagnostic and /fl options and noticed a big difference in the output between msbuild within commandline and msbuild within ccnet. We are also running Rebuild, Release, and "Any CPU". We don't have Visual Studio installed on the CI server, just Microsoft Build Tools 2015.
What is so special about the way CCNet runs msbuild???
Command line:
"C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild" mysolution.sln /p:Configuration=Release /p:Platform="Any CPU" /tv:14.0 /t:Rebuild
vs. CruiseControl.Net:
<msbuild>
<buildArgs>/p:Configuration=Release /p:Platform="Any CPU" /tv:14.0</buildArgs>
<executable>C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe</executable>
<targets>Rebuild</targets>
<projectFile>mysolution.sln</projectFile>
</msbuild>
Related
I can't build a vs2017 solution from the command line, but I can build from the IDE. Once I've built from the IDE the command line build will work. So the ide is doing something different - what am I missing? Here is what I do for the command line build:
nuget.exe restore mysoln.sln
"E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /m /t:Rebuild /clp:Summary /p:Configuration=Debug /p:Platform="Any CPU" mysoln.sln
The output I get:
"Forms.csproj" (Clean target) (14:3) ->
E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(126,5): error : The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0. [E:\wp\Forms.csproj]
Any ideas how I can make the command line build work?
==============
Update
I tried "E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /m /t:Restore GpsConsole.sln from the command line and it works. But when jenkins runs the exact same command i get the same error
==============
Update 2
The way we got the solution building was :
nuget.exe restore mysoln.sln
"E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /m /t:Restore mysoln.sln
"E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" /m /t:Rebuild /clp:Summary /p:Configuration=Debug /p:Platform="Any CPU" mysoln.sln
I suggest you rethink you command-line approach.
You can make your build script independent of Visual Studio installation, make it using MSBuild version you want, and reusable on a build server.
Short plan
Install Visual Studio Build Tools 2017
Find proper MSBuild
Clean solution
Restore packages
Build solution
Details
Using Build Tools will give you independence from Visual Studio installation.
Download Build Tools for Visual Studio 2017 from Visual Studio Downloads page (direct link)
Command-line arguments documented here: Use command-line parameters to install Visual Studio 2017
All workloads and components are listed here: Visual Studio Build Tools 2017 component directory
You can use PowerShell module VSSetup. Download it or install from here: Github: Microsoft/Visual Studio Setup PowerShell Module
Just run MSBulid with clean target
Help nuget.exe to use proper MSBuild
Run MSBuild with build target (you can add additional required parameters)
# 1. Find MS Build
Import-Module $PSScriptRoot\VSSetup\VSSetup.psd1
$msBuildPath = (Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools).InstallationPath
if ([System.IntPtr]::Size -eq 8)
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin\amd64'
}
else
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin'
}
Write-Output "Using MSBuild from $global:msbuildPath"
Write-Output "MSBuild /version"
$msbuild = Join-Path $global:msbuildPath msbuild
& $msbuild /version
# 2. Clean
& $msbuild "$sln_file" /t:Clean /v:q /nologo
# 3. Restore
$nuget = Join-Path $PSScriptRoot "\.nuget\nuget.exe"
& $nuget restore -MSBuildPath $global:msbuildPath
# 4. Build
& $msbuild "$sln_file" /t:Build /v:q /nologo
I believe your visual studio does have the .net core 2.0 SDK installed, since it is able to build your .net standard 2.0 solution.
But, nuget restore is pointing to an sdk inside the visual studio directory (one of a few that visual studio can use, but not where .net core 2.0 sdk installs to by default).
Your .net core 2.0 sdk is likely located in C:\...\dotnet\...
You'll want to have nuget restore use the msbuild located inside that directory, rather than the one within the visual studio directory.
Hi I need to publish my code using MSbuild.exe and create a package of the publish code to a location.
Need to understand how target file will work and the arguments I need to pass while calling the MSbuild.exe
If you are looking to keep code in a folder the better way to do it is to package it since your intentions are to deploy it to IIS later. That way the deployment will process will be easier and clean.
Below is the command to create and save package to desired location:
msbuild "Your\Solution\location\YourSolution.sln" /t:build /P:configuration="Debug-Dev" /p:platform="Any CPU" /p:VisualStudioVersion=14.0 /p:DeployOnBuild=True /p:CreatePackageOnPublish=True /p:DeployOnBuild=True /p:DeployTarget=Package /p:PackageLocation="\wherever\you\want"
I have a .vbproj which is a VB.NET web application project. I can build the solution that contains this project and then right click on the project and publish locally. No issues from with VS 2013 professional update 3.
I am trying to build this solution and then publish the project outside of VS using the msbuild plugin from within Jenkins CI.
The project does not get published as it says it is skipping unpublishable project.
The command and it output is as follows:
Executing the command
cmd.exe /C C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
/t:Publish /p:VisualStudioVersion=12.0 /p:OutDir=C:/temp/eric
StarWebPortal/StarWebPortal/StarWebPortal.vbproj && exit
%%ERRORLEVEL%% from C:\Tools\Jenkins\jobs\STAR-dev_POC\workspace
[workspace] $ cmd.exe /C
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe /t:Publish
/p:VisualStudioVersion=12.0 /p:OutDir=C:/temp/eric
StarWebPortal/StarWebPortal/StarWebPortal.vbproj && exit
%%ERRORLEVEL%% Microsoft (R) Build Engine version 4.0.30319.18408
[Microsoft .NET Framework, version 4.0.30319.18444] Copyright (C)
Microsoft Corporation. All rights reserved.
Build started 8/22/2014 11:46:51 AM. The target "MvcBuildViews" listed
in a BeforeTargets attribute at "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets
(840,131)" does not exist in the project, and will be ignored. Project
"C:\Tools\Jenkins\jobs\STAR-dev_POC\workspace\StarWebPortal\StarWebPortal\StarWebPortal.vbproj"
on node 1 (Publish target(s)).
_DeploymentUnpublishable: Skipping unpublishable project. Done Building Project
"C:\Tools\Jenkins\jobs\STAR-dev_POC\workspace\StarWebPortal\StarWebPortal\StarWebPortal.vbproj"
(Publish target(s)).
Any idea why it works from within VS and not from the msbuild command line?
You have to configure Jenkins to pass two additional arguments to MsBuild.exe which are /p:DeployOnBuild=true and /p:PublishProfile=your_publish_profile.pubxml.
The command should be like msbuild your_vb_project.vbproj /p:DeployOnBuild=true /p:PublishProfile=publish_profile.pubxml You don't need to specified path to publish_profile.pubxml as long as it's under the same directory with your vbproj.
As of Visual Studio 2013, MSBuild is now a separate component from the .NET Framework and is included in the install with VS. It is also available as a separate download for build servers. It looks like you are using the "old" v4.0 MSBuild path. You need to use the new MSBuild path which is something like C:\Program Files(x86)\MSBuild\12.0\bin. You need to configure the Jenkins MSBuild plugin to use this path.
I'm using MS Build inside a TFS build definition to create a One Click deployment.
Everything is working great but MS Build is ignoring /p:Configuration and using the default app.config instead of the required app.dev.config when creating the exe.config.deploy.
Is there a difference property that I should be using?
Here is the MS Build I am using.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "C:\Builds\70\UTI-IT\LMSIntegrationTool_CO_QA2\Sources\src\LMSIntegrationTool\LMSScheduling.sln" /m:1 /fl /flp:"logfile=C:\Builds\70\UTI-IT\LMSIntegrationTool_CO_QA2\Sources\src\LMSIntegrationTool\LMSScheduling.log;encoding=Unicode;verbosity=diagnostic" /target:publish /p:SkipInvalidConfigurations=true /p:DeployOnBuild=True /p:Configuration=DEV /p:DeployPublishMethod=WMSVC /p:MsDeployServiceURL=corpdevweb11 /p:AllowUntrustedCertificate=true /p:ApplicationVersion=1.0.30301.5 /p:OutDir=\\prdtfsbld01\drops\LMSSchedulerTest\\ /p:PublishDir=\\prdtfsbld01\drops\LMSSchedulerTest\\ /p:OutDir="C:\Builds\70\UTI-IT\LMSIntegrationTool_CO_QA2\Binaries\\" /p:RunCodeAnalysis="False"
Slow Cheetah wasn't installed on the build server. Thank you for the responses.
I am trying to configure CruiseControl .net to build our repository code periodically and run the tests included in the solution. I have configured the retrieving code from the svn server and building part. But I am unable to run tests on it. MSBuild keeps on complaining that.
error MSB4057: The target "Test" does
not exist in the project.
I also tried running the tests through command line to see if that works with the same error. I used: MSBuild.exe TestProject.csproj /t:Test
My configuration is something like this:
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>C:\WorkingDir\build\MainProject</workingDirectory>
<projectFile>MainProject.csproj</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
</msbuild>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>C:\WorkingDir\build\TestProject</workingDirectory>
<projectFile>TestProject.csproj</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
</msbuild>
</tasks>
I would appreciate any hint in the right direction.
You havent explained what test framework you're using, which is pretty key here.
For MSTest, this invocation stuff is part of TFS [as the runner stuff is part of Visual Studio, which is why a Task to run MSTest can not be part of MSBuild, which is part of the .NET Framework -- this is also why MSTest forces [in 2010, a subset of] Visual Studio to be installed on your build server (there are a good few questions around here on that topic)]
For xUnit.net, people do stuff like this
For NUnit there's a task that you can supply a list of files to.
Bottom line - one adds a Test custom target to a .csproj file which triggers the salient MSBuild wrapper task for invoking your test runner.