I'm trying to build a .net core 1.1 project on vsts. The project is developed in vs2017 and it uses the csproj instead of project.json. I have tried multiple options to build id on vsts with the hosted agents (windows and linux).
i have tried the following build steps
Visual studio build
Set to use vs 2017 but i get a warning "Visual Studio version '15.0' not found. Looking for the latest version." And then i get errors because it cant include .net core packages.
.NET Core (PREVIEW)
Cant find project.json. When i set it to use csproj file it gives an error "The file type was not recognized"
Command build step
I tried to run the commands with command build steps. "dotnet build" gives the error that it cant find the project.json file.
Anyone building dotnet 1.1 with csproj on vsts that can help me how to do it?
You can download dotnet SDK manually and run
dotnet build
from command line. So it could be something like this:Inline PowerShell step (I've used Inline Powershell extension by Peter Groenwegen):
Extract files step:
Restore packages:
... and so on
But there is some limitation — you still haven't had .Net Core 1.1 installed at build agent machine so some features may not work. At least
dotnet test
will fail because it requires appropriate .Net Core runtime. Maybe some other features as well.In Visual Studio Team Services, go to Build & Release > Builds and click Edit for the build definition you want to update
Navigate to the Options tab, change Default agent queue to Hosted VS2017, and save.
In VSTS you need to add
netcore exists
as a demand.netcore exists
According to this issue .NET Core projects using
*.csproj
files are not supported yet:https://github.com/Microsoft/vsts-tasks/issues/3311
I've tried the tutorials here, but they also seem to be outdated (I couldn't even get tfx-cli installed on my machine): http://mattvsts.blogspot.nl/2016/11/start-building-aspnet-core-11-with-tfs.html
extending on @Nikolay Balakin's answer, it's true the .NET Core projects using
*.csproj
are not supported yet.You can work around this by installing the latest .NET core on the hosted build environment yourself.
This will allow running
dotnet restore
,dotnet build
,dotnet publish
, anddotnet test
.Use the Inline powershell extension to run a script. You can link to a script, or paste the text in inline. I am running a script which is checked in to the project.
It seems each powershell script will be run in it's own environment, so paths etc. will not persist between scripts, so the installation steps and the build steps need to be combined into one script.
You need to copy the dotnet installation script from github and add your own build commands to the end.
I know this is not a long term solution, but we justified it by assuming the VSTS will in the near future support the *.csproj files, and we will convert to use the official build task.
Here is an example powershell script, showing the last line of the installation script, and the custom build commands on the end.
In my case, I have a .NET Core web app and four library projects, all targeting the full framework since I'm using EF 6.
I tried all of the suggestions here and none of them worked. Building with Visual Studio Build on Hosted Agent 2017 does build the project, but doesn't output any binaries. And all the options above did build as well but didn't generate the output files.
Reading around I found the only way to get the output files was by running
dotnet publish
but this generates a build error because nuget isn't restoring well the packages and msbuild can't find them. After being tired of trying to make it work during a whole day, casually I enabled the "Restore Nuget Packages" on the VS Buid task, and though it says it's deprecated, that seems to have solved my isse.