Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild a project from a solution file

Tags:

msbuild

I am attempting to kick off a .net Build using MSBuild from RTC (BuildForge). I keep getting the following exception:

error MSB1009: Project file does not exist. Switch: F:\Program Files (x86)\IBM\Build Forge\Agent\Captiva_Build_dotNET\BUILD_117\xxxxxx\Source Code\Components\xxxxxx\xxxxxxx.sln

The build command is as follows

MSBuild.exe "xxxx.sln" /t:xxx_yyyy_zzzzzz_asdfasdf_base

Where /t: Is one of the projects in the solution. I don't understand what I am doing wrong. I have the _ in the statement. That should be an easy build? Any ideas?

like image 435
SoftwareSavant Avatar asked May 19 '14 21:05

SoftwareSavant


People also ask

How do I create a project using MSBuild command line?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

What is MSBuild project file?

When you create and build solutions in Visual Studio, Visual Studio uses MSBuild to build each project in your solution. Every Visual Studio project includes an MSBuild project file, with a file extension that reflects the type of project—for example, a C# project (. csproj), a Visual Basic.NET project (.

How do I publish a solution using MSBuild?

You can use the created profile to publish from the command line with a command line the following. If you want to store the publish profile (. pubxml file) in some other location you can pass in the path as the value for the PublishProfile property. Publish profiles are MSBuild files.

How do I create multiple projects in MSBuild?

You can use MSBuild to build multiple projects faster by running them in parallel. To run builds in parallel, you use the following settings on a multi-core or multiple processor computer: The -maxcpucount switch at a command prompt. The BuildInParallel task parameter on an MSBuild task.


1 Answers

msbuild.exe /t:target is used to execute a particular target within a solution or project.

msbuild.exe MySolution.sln /t:Clean

To build a particular project you'd specify the project file rather than the solution.

msbuild.exe MyProject.csproj

Edit:

Eureka, you're absolutely right, I have used the MsBuildEmitSolution env variable to output the metaproj script, but never seen that before.

So before you can arrive at this:

MsBuild.exe MySolution.sln /t:ProjectName:TargetName

At the command line, set MsBuildEmitSolution:

set MsBuildEmitSolution=1

Then generate your metaproj.

MsBuild.exe MySolution.sln /pp

Open the output file MySolution.sln.metaproj in notepad and scroll down and find the relevant <Target /> node you wish to build and note the Name attribute string.

  <Target Name="Client_Test:Build">
    <MSBuild Condition="'%(ProjectReference.Identity)' == '...Client_Test.csproj'" Projects="@(ProjectReference)" Targets="Publish" BuildInParallel="True" ToolsVersion="$(ProjectToolsVersion)" Properties="..." />
  </Target>

And VOILA!

MsBuild.exe MySolution.sln /t:"Client_Test:Build"
like image 200
Nicodemeus Avatar answered Oct 12 '22 19:10

Nicodemeus