How to build a VS2010 configuration of a VS2015 solution using MSBuild? - msbuild

I have a Visual Studio 2015 C++ project (solution) of which most build configurations use the VS2015 toolset. However, some configurations are set to use the VS2010 toolset because they link to 3rd party libraries built using VS2010.
All configurations build successfully from within the IDE, and the VS2015 configurations build successfully using MSBuild on the command line, but I am having trouble building the VS2010 configurations using MSBuild.
I invoke msbuild as follows:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
msbuild MSVC\mysln.sln /p:Configuration="myVS2010Config" /p:useenv=true
For the VS2010 configuration I get error:
error C2039: 'gets': is not a member of 'std'
which suggests that the VS2015 compiler is being invoked, not the VS2010 compiler.
Why isn't MSBuild invoking the VS2010 tools?

Related

Visual Studio 2022 MS Build Toolversion and its Framework

What is current Toolversion for MS Build ToolVerions for VS2022 and what would be Framework version for .NetFramework. what is the version i can see in CsProj in project
Visual Studio 2022 ToolVersion in Csproj for .NetFrameWork
Here is the Description of ToolsVersion:
The version of the Toolset MSBuild uses to determine the values for $(MSBuildBinPath) and $(MSBuildToolsPath).
MSBuild is installed in the \Current folder under each version of Visual Studio. You just need to change ToolsVersion="15.0" to ToolsVersion="Current" if you want to use MSBuild 17.0 in your project in Visual Studio 2022.
You can find the current folder from here C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current
We can also see this from the detailed build output window:
Project file contains ToolsVersion="15.0". This toolset may be unknown
or missing, in which case you may be able to resolve this by
installing the appropriate version of MSBuild, or the build may have
been forced to a particular ToolsVersion for policy reasons. Treating
the project as if it had ToolsVersion="Current". For more information,
please see http://go.microsoft.com/fwlink/?LinkId=293424.
The build may have been forced to ToolsVersion="Current" because the toolset for 15.0 could not be found. So it is not necessary to modify ToolsVersion.
For Visual Studio 2022 and .Net Framework projects use ToolsVersion="Current" or ToolsVersion="17.0". (The version of MSBuild that comes with VS2022 is 17.0.)
See more detail at MSBuild Toolset (ToolsVersion).
When a new project is created Visual Studio uses a template. From the comments it appears that the template has not been updated since VS2017 and has ToolsVersion="15.0". MSBuild 15 was provided with VS2017. You can simply edit the project file and update the ToolsVersion. If you only have VS2022 or MSBuild v17 installed, that version of MSBuild will be used even when the ToolsVersion is set to 15.

how to solve Jenkins Build Failed Error :MSB4041

I have build this project as .Net standard project and i am facing this error issue in jenkins when I build this project:
C:\Users\tahab.jenkins\workspace\Mondaytest\Calculator\Calculator.csproj(1,1):
error MSB4041: The default XML namespace of the pr.oject must be the
MSBuild XML namespace. If the project is authored in the MSBuild 2003
format, please add
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the
element. If the project has been authored in the old 1.0 or
1.2 format, please convert it to MSBuild 2003 format
Make sure you use recent versions of the MSBuild task you use to build your project.
You need too use the Visual Studio 2017 (Build Tools, Full, ..) version of MSBuild - which is local to the Visual Studio installation - to build your project.
You may need to confiure the path to MSBuild, which would be - depending on the version installed on the build gent - similar to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
This error happens if you try to build new projects with older versions of Visual Studio / MSBuild or even with the old version of MSBuild that is part of .NET Framework.

How to compile Visual Basic into .exe manually? [duplicate]

I am trying to compile my Visual Basic .NET project named Myproject.sln via command line commands. I need to build and compile that solution.
My Visual Basic .NET compiler is called vbc.exe. Any idea how I do that thing?
I am using Visual Studio 2005 , and I have already read Microsoft's tutorial, "Building from the Command Line (Visual Basic)".
The .NET framework (version 2 and above) comes with a command line build utility called MSBuild.
You can use this to build your Visual Studio project/solution files.
From the command line:
msbuild Myproject.sln
Just run MSBuild and specify the .sln file as a command line option:
msbuild myproject.sln /p:buildmode=release
You could look at using MSBuild. That's probably the best approach.
Your .sln file is a valid MSBUild project file, so if you open the Visual Studio command prompt from the start menu and browse to your project location,
c:\...\msbuild MyFile.sln
... for example, it should just work.

MSBuild error when specifying PublishProfile for ASP.NET.Core project

I have an ASP.NET Core 1.1.2 project targeting .NET Framework 4.6.2. I recently installed the latest version of Visual Studio (15.2 26430.16), and now I can't build the project using MSBuild version 15.1.1012.6693. The error occurs when using a PublishProfile.
The MSBuild command is:
msbuild D:\project\project.csproj /p:DeployOnBuild=true /p:PublishProfile=dist
And the error is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(54,5):
error MSB4062: The "TransformWebConfig" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll.
Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[D:\project\project.csproj]
It works when not specifying a publish profile. However when publishing the project from Visual Studio, everything works as expected.
This is known bug of the tooling when building using the 64 bit MSBuild version (build server, command line). See this GitHub issue for details.
Since this issue has been fixed, you need to upgrade to the recently released 15.3.* versions of Visual Studio / MSBuild and probably also 2.0.0 version of the .NET Core SDK.

Building a msi Installer using MSbuild

I have a Dotnet Windows application built using visual studio 2015.
I am trying to automate the build using MSbuild and Jenkins.
The output files are Setup.exe & MyAppSetup.msi.
I want to use MSbuild and the VS2015 solution file, without using the VS IDE.
The Visual studio solution has 6 projects and all the projects should be built together to generate the .msi installer.
The setup.exe and .msi files are being built using the setup project file(.vdproj).
How do I build the same solution using MSBuild ?
msbuild does not have support for setup projects.
To integrate with Jenkins, you will have to use devenv (VS IDE).
Note: starting VS 2013, vdproj support is provided by an add-in.
Find more information on the following blog: https://juristr.com/blog/2014/03/Jenkins-Build-Setup-Project/