So I’ve finally got my VSTS builds running on Ubuntu (and Windows). I haven’t installed Linux on a PC in well over a decade but it has come a long way in that time.
- Installed Ubuntu 16.04 on HyperV on my Windows 10 dev box. Just boot the HyperV machine to an Ubuntu install disc. That was easy!
- Update the project.json file of my .NET Core console host
- to build a self-contained application (not required but I figured it would help prevent any deployment weirdness later on)
- to target windows and ubuntu so I can use the “dotnet publish” command
"runtimes": {
"win10-x64": {},
"osx.10.11-x64": {},
"rhel.7.2-x64": {},
"ubuntu.14.04-x64": {}
} - Include my game data folder in the publish output
"publishOptions": {
"include": [ "GameFiles" ]
},
- Updated the VSTS build to include two command line tasks to do the publish for both Windows and Ubuntu
- Add a Command Line Task
- Set the Tool to “dotnet”
- Set the Arguments to “publish –output $(build.artifactstagingdirectory)/publish/ubuntu.14.04-x64 –runtime ubuntu.14.04-x64 –configuration Release”
This publish command will publish the given runtime package to the directory that will ultimately be copied to the drop folder by the rest of the process
On this I step originally wasn’t paying attention to the dialog and put the entire command line in the “tool” text box. That won’t work and you’ll get an error claiming the tool executable can’t be found. That took a while to chase down in my case because a lot of the older posts/forums discuss how to get the dotnet tooling installed into a VSTS Build agent – but it is now built in (Its at C:\program files\dotnet”)
- After a build is performed the drop folder looks like this
I left in the original “Copy Files to” step in the build so that I had access to everything that was built as things progressed. But to run things I just need the folders under the “publish” directory - Log in to Ubuntu and download the publish directory
- Last step is to run it
So the current overall workflow now is
- Update the project on Windows in Visual Studio Community 2015
- Check in to Github
- VSTS automatically builds, runs unit test, and packages
- Download to Windows or Ubuntu to run
Next I’m thinking “What could be better than running a 35 year old text adventure on Azure Service Fabric?”