Travis CI recently added a Windows OS option to its build system. Unfortunately, the preinstalled packages only include Visual Studio 2017.
How can I build Visual Studio 2019 projects (such as .Net Core 3.1 and v142 build tools projects) on Travis?
The key to using updated build tools is Chocolatey, the Windows package manager. As long as the toolset is available on Chocolatey, you can install it on your Travis VM.
For .Net Core, that means installing the dotnetcore-sdk package.
For VC++ build tools, there is the visualstudio2019buildtools package, but note you will have to opt in to the Microsoft.VisualStudio.Component.VC.Tools.x86.x64 feature. See below for syntax. A full list of features is available in the Build Tools component directory.
Here's a full .travis.yml
file for a VS 2019 solution containing a C++ project, a .Net Standard 2.0 project and a .Net Core 3.1 project. The test project makes use of the unmanaged DLL.
os: windows
language: cpp
env:
- MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
install:
- choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
- choco install dotnetcore-sdk
- dotnet restore
script:
- export PATH=$MSBUILD_PATH:$PATH
- MSBuild.exe -p:Configuration=Release -p:Platform=x64 CppProject/CppProject.vcxproj
- dotnet build --configuration Release
- dotnet test DotNetProject.Tests/bin/Release/netcoreapp3.1/DotNetProject.Tests.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With