How can override platform tool set for msbuild from command line? How I am doing it is not working - msbuild

I am pulling in open source project but it is configured to build using MS VS 2015. I am trying to override this command line option on msbuild. But is still tries to use MSVS 2015. Following is my command invocation:
msbuild path/to/solution/file/file.sln /p:ToolsVersion=15.0 /p:PlatormToolset=v141 /p:WindowsTargetPlatformVersion=10.0.19041.0 /p:Configuration=Release
I get following error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.target
s(67,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 b
uild tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by sele
cting the Project menu or right-click the solution, and then selecting "Retarget solution".

Related

Upgraded from VS2019 to VS2022 and now msbuild throws "target 'Build' does not exist in the project" error

I wrote my small F# library in Visual Studio 2019, using msbuild v16. I just upgraded to Visual Studio 2022 with msbuild v17. While my solution still builds in Visual
Studio 2022, it does not build from the command line using msbuild, like:
msbuild MyLib.sln
When I run the msbuild command I get the error:
MSB4057: The target 'Build' does not exist in the project
I can't figure out why msbuild would succeed when called by Visual Studio, but not from the command line.

Where is cmake located when downloaded from visual studio 2022

Where is cmake located when downloading it from visual studio 2022 as I wanted to add it in environmental variables
Launch the Native Tools Command Prompt (accessible via the Start Menu). From here you can run:
> where cmake
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
to determine the location. I expect that for VS2022 the path will be very similar.
However, the version of CMake distributed with Visual Studio has patches from Microsoft. You should either install upstream CMake for use outside of the Native Tools Command Prompt, or just use the Native Tools Command Prompt.

Visual Studio Build Tools 2017 for Office VSTO

I have installed the vs build tools 2017 on a build server.
When I try to build with /t:Publish /p:PublishDir="pub/"
I get
_DeploymentUnpublishable:
Skipping unpublishable project.
Is there a way to fix this or do i need to install the full VS with office developer tools?
Is there a way to fix this or do i need to install the full VS with office developer tools?
I got the same error with your MSBuild arguments on command line:
You need to configure the MSBuild command line on your build server with those two additional arguments: /p:DeployOnBuild=true and /p:PublishProfile=your_publish_profile.pubxml instead of /t:Publish /p:PublishDir="pub/.
So the MSBuild command line should be:
msbuild.exe "YourProjectName.csproj" /p:DeployOnBuild=true /p:PublishProfile=PublishProfileName.pubxml
Of course, you need create the publish profile .pubxml, You don't need to specified path to publish_profile.pubxml as long as it's under the PublishProfiles directory with your project file.
Update for Ant`s comment:
Since your project type is a "Excel 2013 and 2016 VSTO Add-in", not "Excel Web Add-in", we should use ClickOnce publish method to deploy project. I have created a sample demo with VS 2017 and build it with TFS 2017. You can check if it helps:
Create a Excel 2013 and 2016 VSTO Add-in project with VS 2017.
Publish this project from VS manually, then ProjectName_TemporaryKey.pfx file will be generated. Check this project include .pfx file into TFS.
Edit build definition with MSBuild task. and add /t:Publish /p:PublishDir="pub/" to MSBuild argument:
Save and build this project.
According to the build log, this project publish successfully:
Note: Add the .pfx file to your build server and my build server installed VS 2017, but AFAIK, you do not need to install the entire VS, you should install the workload Office/SharePoint development:

MSBuild 15 missing after installation

I have recently upgraded to VS2017 and building with TeamCity. I have a new project that I need to build using TeamCity.
I tried to install MS Build on the CI server from the following link https://www.visualstudio.com/downloads/ it said that it has successfully installed it. Restarted the CI server trying to build the project and still cannot find the new Build tools.
I checked under C:\Program Files (x86)\MSBuild\15.0\ but I dont see the MSBuild.exe
MSBuild 15 missing after installation
If you want use MSBuild without install Visual Studio, you should download and install vs_BuildTools.exe from below link:
https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#
After installation complete, you will find the MSBuild.exe under the path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
For more detail information, you can refer to: How can I install the VS2017 version of msbuild on a build server without installing the IDE?
MSBuild is now local to Visual Studio 2017
and multiple versions can be installed side-by-side (e.g. build tools, previews, community + enterprise, etc.)
So a path to msbuild.exe could look like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

How to build a VS2015 solution that has a VS2010 configuration using MSBuild?

I want to build a Visual Studio 2015 C++ solution from the command line using MSBuild. The complication is that I want to build a particular configuration of the solution, which uses the Visual Studio 2010 toolset (necessary because I am linking to a 3rd party library).
I have used MSBuild successfully in the past, but am unsure of which versions of MSBuild and vcvarsall.bat to use in this case. Currently I am running:
"\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
"\Program Files (x86)\MSBuild\14.0\Bin\MSBuild" mysolution2015.sln /p:Configuration="2010_Config" /p:useenv=true
but that gives error:
LINK : fatal error LNK1117: syntax error in option 'manifest:embed'
Any help would be appreciated.
You should be using the vcvarsall.bat from VS2015 ("\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat")
The chosen configuration will select the appropriate toolset (assuming you have both VS2015 and VS2010 installed).
You can then simply use msbuild has it will have been added to the path...