Reputation: 11
I am trying to build a solution using MSBUILD. Instead of building the solution, it launches the Visual Studio.
E:\MyProject> <path to MSBuild>\msbuild.exe MySolution.sln
I am calling the Msbuild step from the Jenkins and due to the above issue it is getting stuck. Can anyone help me out here?
Upvotes: 1
Views: 300
Reputation: 23848
When I tried to build my solution using MSBuild, its launches Visual Studio
Usually, VS IDE will start only when devenv.exe
is called.
First, please check every proj
file under the solution folder and make sure that there is no such bat file or command to call denenv.exe
in proj
file.
enter every xxx.csproj
or xxx.vcxproj
file, check if there is something similar to the following:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command=""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe"
 
" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command=""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe"
" />
</Target>
<PropertyGroup>
<PreBuildEvent>"C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\Common7\IDE\devenv.exe"</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>"C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\Common7\IDE\devenv.exe"</PostBuildEvent>
</PropertyGroup>
If so, you should delete them and make them not call devenv. devenv will start VS IDE.
Second, you should call msbuild version like:
MSBuild of VS2017:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
MSBuild of VS2019:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
Use MSBuild Command Line on Jenkins like this:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe xxx\MySolution.sln /t:build
Besides, you can also check whether Jenkins has a job to call devenv
. If so, you should remove it.
Upvotes: 2