Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
823 views
in Technique[技术] by (71.8m points)

visual studio 2010 - How do I target a specific .NET project within a Solution using MSBuild from VS2010?

I have an MSBuild command line that can build an entire solution. It looks something like this:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Build

I know that for C++ Solutions, specific projects can be targeted using the following syntax:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:FolderSomeCppProject;Build

I'm trying to achieve the same thing for .NET projects within a solution. This does NOT work:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:SomeDotNetProject;Build

Does anyone know how to target a specific project within a solution using MSBuild on the command line for .NET projects? I know I can create a custom MSBuild project to achieve what I'm after, but I need to share the solution and projects with Visual Studio.

Thanks!
-Sean

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You'll need to specify any solution folders in the Visual Studio solution file, and replace any "." in the project name with "_":

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:FolderProject_Name

For example, if you have a project in the solution folder "Deploy" named "MyApplication.Deployment.csproj", you'll need

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:DeployMyApplication_Deployment

Incidentially this is a solution folder, as displayed in Visual Studio, not a file system folder: those are ignored.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...