简体   繁体   中英

When I tried to build my solution using MSBuild, its launches Visual Studio

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?

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="&quot;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe&quot;&#xD;&#xA; &#xD;&#xA;" />
      </Target>
    
      <Target Name="PostBuild" AfterTargets="PostBuildEvent">
        <Exec Command="&quot;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe&quot;&#xD;&#xA;" />
      </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.

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