Passing custom msbuild target from solution to project

I have a solution with a lot of related .csproj files.

Each .csproj file has <Target Name="PublishQA">...

The build failed while trying to compile the whole solution:

 > msbuild mysolution.sln /t:PublishQA` "c:\myproj.sln" (publishqa target) (1) -> c:\myproj.sln.metaproj : error MSB4057: The target "PublishQA" does not exist in the project. [c:\myproj.sln] 

When I create a .csproj project directly, it builds just fine.

How to tell msbuild to transfer target to project files ???

+7
source share
1 answer

As an example, you can create a separate goals file that explicitly creates your solution,

 <!-- mytargets.targets file --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="MyTargets" InitialTargets="MyTargets"> <Target Name="MyTargets"> <MSBuild Projects="MySolution.sln" /> </Target> </Project> 

So now you can just call it like

msbuild.exe mytargets.targets

+2
source

All Articles