command line solution build using devenv rebuilding more projects than visual studio solution build - visual-studio

I am trying to mimic visual studio solution build from command prompt using batch script but there is significant difference between manual solution build(ctrl+shift+b) inside visual studio and command line solution build using devenv in terms of project rebuild counts. More projects are getting rebuilt from command line in comparison to visual studio solution build.
I am using this for command line build in batch file:
call"C:\ProgramFiles(x86)\MicrosoftVisualStudio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
devenv solution_name.sln /build "Debug"
command line solution build output looks like this: devenv solution build using cmd prompt
visual studio solution build output looks like this: manual vs solution build output
I have tried changing the configurations too but it didn't help, I am curious why this might be happening and is there a way to get same result from command line build as of manual vs solution build?

Related

Jenkins - Visual Studio Command line arguments

Planning to Build & Deploy SSIS Projects(ISPAC) or Database Solutions (DAPAC) from Jenkins using Visual Studio Command line arguments.
Question: I know i can execute Windows batch commands but i would like to if i can execute Visual Studio Commands as well.
FYI: Planning to install Visual Studio on the Agent.
I think you will be able to do it using msbuild. If your SSIS solution can be compiled by Visual Studio, the msbuild command can do it as well (See also msbuild integration).
To utilize msbuild to create an ispac/dapac file take a look at this article. It's not Jenkins specific but that should not matter.

DevEnv to build BizTalk Visual Studio 2013 solution from command line

I'm running the following:
D:\GitRecompile>"c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" MyFolder\MyApp.sln /build "Debug"
It gives no error, no results, nothing. Almost like I just hit enter from the command line.
I'm trying to do a batch rebuild of several BizTalk Projects from the command line to make sure all code was checked-in corretly.
I also tried:
D:\GitRecompile>c:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild MyFolder\MyApp.sln /p:Configuration=Debug
It ran, but got a lot of errors, such as xxx.xsd.cs could not be found. BizTalk creates the .cs from the .xsd at build time; so it seems like the build should have created those files.

Why building project using msbuild is way slower than using visual studio IDE?

I'm trying to use the msbuild to build visual studio project using command line.
I used this commands
SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
msbuild.exe ../../../embedded/ports/visualC12/config-from-host.vcxproj
/p:Configuration=Release /p:Platform=Win32 /t:rebuild
Using IDE : it took around 2 min
Using cmdline: it took around 20 min
In command line it looks like it build a lot of projects that are not built in the IDE
Any suggestions?
In command line it looks like it build a lot of projects that are not built in the IDE Any suggestions?
That because you are using the property /t:rebuild in your command.
This switch performs the same function as the Rebuild Solution menu command within the integrated development environment (IDE)-will clean and then build the solution from scratch, ignoring anything it's done before. So MSBuild will build all projects regardless of whether them were built before or not.
When you build projects in IDE with build option ranther than Rebuild, it will perform an incremental build: if it doesn't think it needs to rebuild a project, it won't. It may also use partially-built bits of the project if they haven't changed. That is the reason for a lot of projects build in command line but are not built in the IDE.
To make the build faster, you can change the property to /t:build in command line or select rebuild option when you build in IDE.
Besides, there are many factors that affect the speed of building, for example, parallel. When we build multiple projects in IDE, the default value of parallel is 8, Tools->options->Projects and Solutions->Build and Run:
MSBuild command line is also support parallel, /maxcpucount Switch
msbuild.exe myproj.proj /maxcpucount:3
So when you compare the build speed between the command line and the IDE, you have to make sure that all the relevant settings are the same for command line and IDE.
Hope this helps.

Obtain visual studio generated build command

I want to create a batch file for building releases of a multi-solution software. What I am curious about how may I obtain the exact MSBuild command that Visual Studio executes when I click on "Rebuild Solution"?
It is equivalent to
MsBuild /t:Rebuild /p:Configuration=<config>;Platform=<platform>
although VS actually generates a temporary msbuild file from the solution and then builds that. You get the file by setting an MSBuildEmitSolution environment variable:
open a VS command window
enter set MSBuildEmitSolution=1
enter devenv to open a VS instance within that command window so it uses the MSBuildEmitSolution environment variable
open and build your solution

devenv command line does not show error for defective projects

We use Jenkins to build our solutions automatically. We call devenv (Visual Studio 2010) by a command line: devenv PathToProject\Project.sln /build Release
When the solution contains a defective project (*.vdproj, *.csproj), opening the solution in the Visual Studio IDE will result in an error message. But when building the solution with the above command line, no error message is shown at all, and consequently Jenkins reports success.
if you want to reproduce the problem, just open the vdproj file in an editor, and remove a } somewhere in the file.
How can that problem be solved?
On Visual Studio 2012, /Out writes the build messages to a text file.
devenv.exe YourVisualStudioSolution.sln /build "Debug|Win32" /Out "YourLogFile.txt"
According to MSDN, this switch should work on Visual Studio 2010 as well.

Resources