How can I build Visual Studio 2019 projects on Travis CI? - travis-ci

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

Related

Install TFS client tools to accompany MSBuild 17.x (.net 6 / Studio 2022)

I have installed the vsBuildTools for 2022 in order to assemble a build machine. The build tools do not come with TFS tools to actually download source code.
Where can I get the TFS parts to finish this build server? (I did not want a full Visual Studio 2022 install if possible)

No 'ASP.NET MVC 4' assemblies when installing Visual Studio Build Tools 2017

I have a TeamCity build machine with VS2017 build tools installed. The problem is that I don't see any 'ASP.NET MVC 4' installed in "c:\Program Files (x86)\Microsoft ASP.NET" folder. The assemblies are required to build project that reference e.g. System.Web.Http namespace. When building, I am getting exactly such errors.
When running Visual Studio Build Tools 2017 on TeamCity build machine I have following Workloads installed:
.NET desktop build tools
Web development build tools
Data storage and processing build tools
Individual components tab does not list ASP.NET MVC directly but I have "Advanced ASP.NET features installed.
Do I need to install any external component to enable building of ASP.NET MVC 4 on my build machine? Or maybe it is only including in 'Visual Studio Professional 2017' product, not the 'Visual Studio Build Tools 2017'?
Could it be the case that the installation is broken?
(Microsoft ASP.NET folder contains "ASP.NET Web Stack 5" but as said earier the entire "ASP.NET MVC 4" is missing).
Thanks, Radek
I am not familiar with Visual Studio Build Tools 2017. But you can try installing the standalone ASP.NET MVC 4 package:
https://learn.microsoft.com/en-us/aspnet/mvc/mvc4

'vc_redist.x64 does not install in microsoft/nanoserver image

I want to use microsoft/nanoserver as base image for my requirement and want to install 'vc_redist.x64' package into it but I am not able to install as it returns some error as shown below:
and this is my Dockerfile:
FROM microsoft/nanoserver
MAINTAINER <org name>
ADD . /
CMD ["powershell", "c:/scripts/start.ps1"]
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:\vc_redist.x64.exe /quiet /install
However if I use 'microsoft/windowsservercore' the base image size increases rapidly and it goes to 12+ GB. having large base image size does not fit in my requirement.
Is there any way to install 'vc_redist.x64' in 'microsoft/nanoserver' with its dependencies?
Any help is much appreciated.
Visual C++ Redistributable Packages cannot be installed in NanoServer.
However, you can use the binary dlls manually. The redistributable files are installed with Visual Studio.
Steps:
Open Visual Studio Installer, make sure you check Desktop Development with C++. At right details panel, check all versions you want to install:
MSVC v143 - VS 2022
MSVC v142 - VS 2019
MSVC v141 - VS 2017
MSVC v140 - VS 2015
Find your VS installation folder, for example, VS2022 should be like C:\Program Files\Microsoft Visual Studio\2022\Community and VS2019 should be C:\Program Files (x86)\Microsoft Visual Studio\2019\Community. Then go to the CRT folder.
I have installed VS2022 and want to use MSVC v142, so the full path should be:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.29.30133\onecore\x64\Microsoft.VC142.CRT
Copy everything under this folder to your application's local folder, or C:\Windows\System32 in your NanoServer image.

Build ASP.NET Core in x86 on TFS

I'm trying to build and deploy an ASP.NET Core 2.0.3 Web API through TFS.
In Visual Studio I've configured Release to target the x86 platform.
I've also ensured the following in the csproj:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<Platforms>x86</Platforms>
</PropertyGroup>
Building locally produces the expected output in folder bin\x86\Debug\netcoreapp2.0
Over in TFS I have a new .NET CORE build configuration with the restore/build/publish tasks. I notice that they don't use the standard BuildPlatform build variable which I've changed from Any Cpu to x86
Build: --configuration $(BuildConfiguration)
Publish: --configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)
They only use BuildConfiguration which is either Debug or Release. This results in an Any CPU dll which will run as x64 on the release server.
I've tried adding -r win7-x86 to the publish command but this has resulted in a self contained deployment being published which isn't what I want.
I've tried adding -r win7-x86 to the build command, which results in the correct dll being produced, but the publish command does it's own implicit build and doesn't use the output of the previous build task.
How can I get TFS to publish an x86 DLL (framework dependent) for the web application?
For .NET Core applications (netcoreapp* - not ASP.NET Core on .NET Framework), the platform used during build usually doesn't matter.
The bitness is determined through the version of the dotnet.exe host that is used to load and run the application. E.g. C:\Program Files\dotnet\dotnet.exe (64 bit) or C:\Program Files (x86)\dotnet\dotnet.exe (32 bit).
The RuntimeIdentifier MSBuild property (what the -r switch sets) is only relevant for self-contained deployments but there is also an option to specify --self-contained false (=> SelfContained MSBuild property) so that a runtime-specific application is built without creating a self-contained deployment. This is typically only needed to filter runtime-specific assets - e.g. only include win-x32 versions of a SQLite native library instead of multiple versions for windows/linux/Mac etc. in a runtimes sub-folder.

Xamarin iOS build server on OSX using Jenkins and Nuget

I am currently building a continuous integration pipeline on an iMac in order to build Xamarin iOS apps. We are using Jenkins to control the CI build process but the project contains a number of Nuget packages that are not stored in our Git source repo. As these packages are not downloaded by Jenkins I need to call a Restore on the solution.
Is Nuget.exe installed as part of Xamarin Studio on OSX (and if so where) and if not is there an OSX command line version for El Capitan?
The Mono installer on OS-X supplies a nuget shell script and the nuget.exe CIL-assembly
Default install location of script:
/usr/local/bin/nuget
Script contents:
#!/bin/sh
exec /Library/Frameworks/Mono.framework/Versions/4.4.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/nuget/NuGet.exe "$#"
Nuget version:
As of Mono 4.4.0, the nuget version is:
NuGet Version: 2.8.5.0
Nuget restore:
In the root of your solution, all you have to do is call nuget restore with your solution, i.e.
>nuget restore mysolution.sln
All packages listed in packages.config are already installed

Resources