简体   繁体   中英

MSBuild successful but Visual Studio failed

We're using Jenkins to build out projects using msbuild.

I added a project reference to an existing project but forgot to add these new project to all solution files.

I committed but Jenkins told me that everything works fine. I tried that on command line:

msbuild test.sln /t:Rebuild /p:Configuration=Debug

Having a totally cleared working directory that works fine, in Jenkins and on my developing machine. The output told me that msbuild found that project and build it.

But if I open Visual Studio 2017 and try to build that solution, it tells me that the depending project could not be found.

That's correct.

How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?

BTW: We don't need a hint how to find all solutions that need to contain that new project. Finding that solutions is pretty easy.

How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?

The correct way to avoid MSBuild's default behavior of rebuilding all the dependencies listed in the solution file is to set the BuildProjectReferences property to false, So the build command line should be:

MSBuild Test.sln /t:Rebuild /p:Configuration=Debug /p:BuildProjectReferences=false

After using this command line, MSBuild will get the same error with VS, so we're able to find all solutions that missed that new project

在此处输入图片说明

Note: BuildProjectReferences will check all the dependencies listed in the solution file, so please keep his value is true, unless used to check the missing dependencies.

Hope this helps.

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