简体   繁体   中英

Unable to invoke Build target using msbuild command line on a solution file

I have a solution with many projects organized in solution folders. I am trying to invoke Build target on a project of the solution using solution.sln file. The msbuild errs out saying Build target is not available in the said project. I can invoke Clean target, Rebuild target on the same project, but not build.

Wondering what I am doing wrong. Below is the command line that I am using:

msbuild..\Galaxy.sln /p:Configuration=Debug /p:"Platform=Any CPU" /t:"DataTools\CLIUtils:Build"

The error: error MSB4057: The target "DataTools\CLIUtils:Build" does not exist in the project. [ snip \Galaxy.sln]

I am using Visual Studio 2019. I also checked https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe?view=vs-2015 which describes target invocation for solutions. This looks like a bug to me.

We can produce an MSBuild file named.sln.metaproj use this method and check this file we can see targets like Clean, Rebuild, Publish, Restore but not Build target.

在此处输入图像描述

You can try CoreBuild target, it works in my test:

msbuild ..\Galaxy.sln /p:Configuration=Debug /p:"Platform=Any CPU" /t:"DataTools\CLIUtils:CoreBuild"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM