I tried to google it but couldn't find it. I want to Disable /Qspectre from command line.
Note: I am trying this inside docker container i have already
installed component for it.But still i am getting error MSB8040:
Spectre-mitigated libraries are required for this project.So i want to
disable it and give try. if it works.
docker run -v C:\BuildTools\ConsoleApplication1:C:\ConsoleApplication1 --name CP3 buildtools2019 msbuild C:\ConsoleApplication1\ConsoleApplication1.sln -maxcpucount:3 /p:Configuration=Debug /p:Platform=x64
This is PowerShell command which i am using it to run my project. open for all suggestion and recommendation.
I am afraid there is no direct command line method to disable /Qspectre. I suggest that you could disable it by some other methods.
Put/copy file with name 'Directory.Build.props' to build folder with content:
<Project>
<PropertyGroup Label="Configuration">
<SpectreMitigation>false</SpectreMitigation>
</PropertyGroup>
</Project>
That overrides default VS behavior and disables /QSpectre compiler switch.
You could refer to this link.
Related
I want to, for example, enable showing includes (\showIncludes from C++ compiler Advanced configurations) for some project via MSbuild command line. Can I make it somehow without changing the project properties?
The following command line I tried doesn't work:
MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /p:ShowIncludes=true "myproj.vcxproj" -t:Rebuild
Yes, here are docs. You need to pass /showIncludes:
MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /showIncludes "myproj.vcxproj" -t:Rebuild
Example
I'm trying to create a code coverage report using the Build pipeline.
I have added the task of typeVisual Studio code in the build pipeline and have enabled the Code Coverage.
When the build is triggered. I'm getting :
Data collector 'Code Coverage' message: Data collector 'Code Coverage' failed to provide initialization information. Error: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop' threw an exception. ---> Microsoft.VisualStudio.Diagnostics.Common.InvariantException: Failed to load IntelliTrace Profiler binary or failed to locate functions.
and
---> System.ComponentModel.Win32Exception: The system cannot find the path specified
This is running the tests and all the tests are passed. However I'm not able to view the code coverage report. The report which it has created contains only information about the tests
Any input on where we specify the path will be useful.
You basically need Visual Studio Test Agent for Code Coverage.
There are 2 possible ways to install for this:
Option 1
Install Agents for Visual Studio 2019 on the Build server (download from here, see under Tools for Visual Studio 2019).
In the build pipeline edit the Visual Studio Test Assemblies task. Set Select test platform using to Specific location and set Path to vstest.console.exe to for example C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe.
Option 2
Add the Visual Studio test platform installer build task to your pipeline. (Add this task before the testing task).
In the Visual Studio Test Assemblies task you have to select Installed by Tools Installer as the Test platform version
Note: in my experience I had some tests who succeeded with option 1, but failed in option2. Sadly I don't have the time to figure out why...
I faced this issue when configuring a build container.
1 To install the Visual Studio 2019 Test Agent, I used Chocolatey
1.2 Install Chocolatey
ENV chocolateyUseWindowsCompression = false
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); `
[System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};%ALLUSERSPROFILE%\chocolatey\bin\"", 'Machine'); `
choco feature enable -n allowGlobalConfirmation;
1.2 Install the TestAgent with chocolatey
RUN choco install visualstudio2019testagent -y
2. Edit the VSTest task on your pipeline to use a specific location.
In my case, I've installed into the container the VSBuildTools. The VSTest task used the VSBuildTools vstest.console.exe but the execution needs some libraries that are located at the TestAgent folders.
vstestLocationMethod: location
vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe'
Had a similar problem after updating build agent and adding VS2017 capabilities.
Downloaded (from https://www.opendll.com): microsoft.intellitrace.profiler.dll
Add to folder C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\TestPlatform\x64
Good luck
I have VS2017 installed and a target file I have a target file
<Target Name="TargetName">
<Exec Command="some-command"></Exec>
</Target>
Target command runs fine. Except it run in cmd instead of developer command prompt. Previously, it used to run in developer command prompt.
I know this because it is not able to find variable VCINSTALLDIR and also nmake command. When I run the same command from developer prompt, they work as expected.
I have reinstalled VS2017. Still the issue persists. Is there any setting in VS2017 to make it use developer prompt?
I solved my problem by adding vsdevcmd.bat in the PATH environment and changing command to
<Exec Command="call vsdevcmd.bat & some-command"></Exec>
In previous versions of MSBUILD you can build all configurations in a solution using the following command line arguments:
msbuild /t:BuildAll /Configuration:"Debug;Release;ContinuousIntegration"
as shown here
However this does not work with MSBUILD VS2015 and gives the following error:
MSBUILD : error MSB1006: Property is not valid.
Switch: Release
This is a similar question to the one here however I am not using cmake just simply straight MSBUILD
For example:
C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe"Uninstaller.vcxproj /property:Configuration=Release'
Sometimes you need run this for setting environment
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat"'
I've recently been busy working on making proper build scripts for a code library I've been designing, and have been stuck on getting MSBuild to properly compile for my Windows builds. What I'm trying to do is call MSBuild from a batch script without it opening the Visual Studio IDE, which it appears to constantly do if I'm not executing it from the Developer Command Prompt for Visual Studio. My script is simple enough, just calling
start C:\Program Files (x86)\...\MSBuild\15.0\Bin\MSBuild.exe <Project>.sln
Besides a few other specifiers tagged onto the end of it, that's what I'm trying to use to run my Windows builds. The issue here is that whenever this code is called outside of the VS Dev Prompt, Visual Studio itself opens, not building the code at all. I couldn't find anyone else struggling with this same issue either, as it seems to be new to the integration of MSBuild and Visual Studio. Testing with older versions of MSBuild went to show that I could build projects as I wanted to outside of the Dev Prompt. Could I be missing some environment variable supplied in the Dev Prompt that changes the executable behavior? I couldn't seem to find any executable specifiers that would change this, either.
Maybe I'm taking a completely wrong approach to this problem? My end goal is to provide consumers with a collection of build scripts, one for each platform they're targeting, so I am definitely open to other solutions.
The canonical answer:
You can use the devenv command with the /build command line option and the name of your project file.
Alternatively, you can run one of the vcvars*.bat scripts to set up the necessary environment and then use msbuild.
For more info, see https://learn.microsoft.com/en-gb/cpp/build/building-on-the-command-line.
Update: Contrary to the official advice above, this is what works on my laptop with VS2017 community edition.
Setup the environment by running the bat file that is targeted by the "developer command prompt for VS2017". (Right-click on that in the start menu, then select "Open file location" then right-click on the shortcut and select "properties". For me that is "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat".
You should call this file from your build script.
cd to your project directory and then use msbuild like this:
msbuild My-project.vcxproj /p:Configuration=Release
For some really strange reason I can use the devenv method if I open the official developer command prompt but launching devenv from another command prompt even with the environment variables set does nothing. (And I even compared the set of environment variables in both command prompts and they are equal.)
How to Run MSBuild Outside of the MSVS Dev Prompt?
If the necessary environment not be set correct, then the build command becomes " mysolution.sln". And executing it indeed starts VS. So you should run the vcvars*.bat scripts to set up the necessary environment and then use msbuild. Following is my a batch script, it has been working for some time, you can check it:
#echo OFF
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
echo "Starting Build for all Projects with proposed changes"
MSBuild.exe "C:\Users\Admin\Source\repos\MyTestProject\MyTestProject.sln"
pause
echo "All builds completed."
Here is the test sample result:
See How to create a Simple Build Script for Visual Studio from the Command Line? for more details.