Monday, 17 April 2017

Building ASP.NET Core 1.1 Web App with Team Services

ASP.NET Core 1.1 is available with Visual Studio 2017 and it is based on .csproj to provide us with a consistent experience inside Visual Studio. .csproj will be the way forward with ASP.NET Core and Microsoft encourages everyone developing on ASP.NET Core to move to Visual Studio 2017. You can see the recommendation in https://blogs.msdn.microsoft.com/dotnet/2017/03/07/announcing-net-core-tools-1-0/ quoted below. Microsoft will not be updating VS 2015 based tools for .NET core anymore.

 

Migrating project.json Projects to csproj

We’re now encouraging everyone to migrate to MSBuild and csproj from project.json. As I stated above, we will not be supporting any of the new .NET Core tools in Visual Studio 2015. We also won’t be updating the Visual Studio 2015 project.json-based tools.

There are two experiences for migrating project.json projects. You can migrate project.json files on the command-line, with the dotnet migrate command. The command will produce a .csproj project file that you can use with the latest .NET Core tools or open in Visual Studio 2017.

You can also open .xproj files in Visual Studio 2017. Visual Studio will migrate your .xproj files for you, producing a .csproj file that you can use going forward for use with both Visual Studio 2017 and with the latest .NET Core tools at the command-line.

Let’s look at Team Services build definition that can build an ASP.NET Core Web Application developed with VS 2017. 

1. In your build definition make sure to select the Hosted 2017image

2. Define variables for build configuration and build platform.image

3. Add a command line task and add tool as dotnet and argument restore. Set the working folder to web project folder path.image

4. Add a Visual Studio Build task and use build configuration and platform variables and version of Visual Studio as 2017.image

5. Add command line task and use dotnet for the tool. Arguments should be publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory). For the working folder provide the web project path.image

6. Add an archive files task. Provide $(Build.ArtifactStagingDirectory) as the Root folder. Make sure to uncheck the “Prefix root folder name to archive paths”. Provide zip as Archive type and $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip as the “Archive file to create”.image

7. Add Publish Artifacts task and provide $(Build.ArtifactStagingDirectory))/$(Build.BuildId).zip as”Path to Publish”. image

Save and queue a build and you will be able to download the published ASP.NET web app zip file from the Build artifacts.image

No comments: