Search code examples
visual-studioconfigurationmsbuildrelease

MSBuild offline installer that comes with visual studio 2017 build tools not able to build project in Release mode


Step 1 - I have installed visual studio build tools by downloading vs_BuildTools.exe from this site (you will require to login to microsoft account to browse this URL)

Step 2 - I created offline installer by following various articles particularly this one

And created zip file offlineBuildTools17.zip

Step 3 - Copied offlineBuildTools17.zip file to Build server which doesn't have internet connection.
Build server is Windows server 2012 R2.

Step 4 - Extracted Zip file on server and installed Build tools. Installation goes smoothly.
I could see installation files in

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft

Step 5 - I have simple DLL and Console application (.exe) project in my solution. These are simply 'hello world' application NOT USING DOT NET CORE. I am using .net frameowrk 4

Problem: I am unable to create release mode dlls and exe

Same thing is working on my laptop where I have installed visual studio 2017 community edition. On laptop where visual studio 2017 installed

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild"  <optional project.csproj> /p:Configuration=Release

This creates dlls and exe in bin\Release folder of project

But the same doesn't work on Build server. Always creates dlls and exe in bin\debug folder.
My final goal is to create 'publish' folder


Solution

  • This is weird but it is solving my problem. if i ran following command - msbuild is always generating Debug binaries. which was my original problem. it doesn't generate release mode binaries at all

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\"msbuild /p:Configuration=Release /t:publish /p:OutDir="./Publish"
    

    But if i write following command , (note how msbuild is placed in double quote along with mbuild full path) it is working fine. it generates release mode binaries and also publish folders.

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild" /p:Configuration=Release /t:publish /p:OutDir="./Publish"
    

    thanks