Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a TeamCity build for a ASP.NET 5 project

I'm trying to setup a CI server for a website that I'm developing, but I can't find any info regarding how to do it with the new ASP.NET 5.

like image 616
edua_glz Avatar asked May 22 '15 16:05

edua_glz


People also ask

How do I set up TeamCity?

Go to Administration | Projects and open the required project. Alternatively, open the project using the Projects pop-up menu and click Edit Project Settings. The Project Settings page will open. On the Project Settings page, click Create build configuration under the Build Configurations section.

How do I manually build TeamCity?

To run a custom build with specific changes, open the build results page, go to the Changes tab, expand the required change, click the Run build with this change, and proceed with the options in the Run Custom Build dialog. Use HTTP request or REST API request to TeamCity to trigger a build.

Is TeamCity a build tool?

TeamCity is a build management and continuous integration server from JetBrains. It was first released on October 2, 2006 and is commercial software and licensed under a proprietary license: a freemium license for up to 100 build configurations and three free Build Agent licenses are available.


2 Answers

I got you brother. This took me a few days to figure out. This configuration is on TeamCity v10 for a ASP.NET Core 1.0 RC2/preview2 project. As a bonus, I am including the step where it pushes to Octopus Deploy. You will need to install the dotnet teamcity plugin and the newest Octopus Deploy plugin with Push functionality. Here's an overview of the build steps:

Build Steps Overview

First off, don't try to use dotnet restore to restore the packages. It won't work if you have internal nuget packages that are not compiled as .Net Core. This took forever to figure out. I would ignore trying to use dotnet restore until people have converted everything over to .Net Core or Microsoft fixes dotnet.exe to be more flexible.

Build Step 1/3

Some of the stuff I read said to use the newest beta version of NuGet, 3.5. When I tried this, I would get the following error.

[14:30:09][restore] Starting NuGet.exe 3.5.0.1737 from D:\buildAgent\tools\NuGet.CommandLine.3.5.0-rc1\tools\NuGet.exe

[14:30:10][restore] Could not load type 'NuGet.CommandAttribute' from assembly 'NuGet, Version=3.5.0.1737, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

I don't know what that means, and I don't care. Use 3.4.4 for now. Fill in the rest as appropriate.

Build Step 2/3

The dotnet publish step is pretty straightforward. Make sure you provide the output directory because you want to use it in the final step. Also, be sure to specify an absolute path by using the %teamcity.build.workingDir% variable because of this bug. Otherwise it will fail to find your web.config file and not finish publishing the entire site. You'll be missing things like web.config and wwwroot! Build Step 3/3

Finally we Push to Octopus. This was very tricky for me. Note the part that says %teamcity.build.workingDir%/published-app/**/* => OrderReviewBoard.1.0.0.zip

IF ANY PART OF THIS IS INVALID, YOUR STEP WILL FAIL WITHOUT EXPLAINING ITSELF!!! By invalid, I mean maybe you put a teamcity environment variable (like the %build.number% they show in all the examples) in that zip name that doesn't properly resolve. Or you specify a non-existent path. Or any number of things, you will see an error that says "[Octopus Deploy] Please specify a package to push". That means that one was never generated because that statement failed. I realize you want to have an auto-incrementing build number there. I'll leave it up to you to figure out how to do that.

Don't get all confused by what is running here. Octopus tries to explain it on their site, but it is hidden here. There is octo pack and octo push. The new version of octo pack is running out of sight, based on whatever statement you put in that "Package paths" box. Don't get sidetracked trying to create a nuspec package, or trying to use dotnet pack. These are dead ends for our purposes. Create a .zip file and move on with your life. Finally, notice the additional command line arguments I added. These help you out a tiny bit. They aren't required. Good luck.

like image 51
redwards510 Avatar answered Sep 25 '22 07:09

redwards510


We (the ASP.NET team) use TeamCity as the build server. Each repo has a build.cmd file, similar to this one. TeamCity simply invokes that file.

For Mac/Linux builds, there is a build.sh file.

like image 20
Victor Hurdugaci Avatar answered Sep 24 '22 07:09

Victor Hurdugaci