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.
-
1http://blog.coderinserepeat.com/2015/01/25/building-asp-net-5-projects-in-teamcity/ – Shrike May 25 '15 at 09:42
-
I started following that article, but ended up using the build.cmd suggested on Victor's answer, I thinks it's easier to follow, although afaik there's no documentation on how to use the tools. – edua_glz May 25 '15 at 16:09
5 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:
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.
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.
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!
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.

- 1,802
- 1
- 17
- 23
-
I can't get this solution to work. The first build step is failing with the following error message: "Error reading 'F:\TeamCity\Files\buildAgent\work\src\solutionname\project.json' at line 13 column 23 : TODO: unknown keyword platform". I've made sure that the latest CLI is installed but it still fails. Did you encounter this, if so how did you solve it? – dont_trust_me Aug 26 '16 at 12:29
-
@Carl91 Open the project.json file in your solution. At line 13 you apparently have an invalid line, a comment of "TODO: something something." Remove that line and push to TeamCity. – redwards510 Aug 29 '16 at 16:51
-
The only thing I had on line 13 was "netcoreapp1.0": {. That framework doesn't seem to be supported in the latest stable release of nuget (3.4.4.). Updated to 3.5.0-beta2 and it worked fine. – dont_trust_me Sep 01 '16 at 09:55
-
@redwards510 tried your soultion (except than I am on TC9, so i use Command Line step `dotnet publish %fullpathtomywui%` manually), and I get an error: `Lock file Microsoft.DotNet.ProjectModel.Graph.LockFile contains msbuild projects but there is no export file` on step 2 – Alex Zhukovskiy Sep 19 '16 at 12:03
-
@AlexZhukovskiy Can you run dotnet publish on the target file in a cmd.exe shell? Does it throw the same error? It doesn't sound like a TeamCity error, but I don't know... – redwards510 Sep 19 '16 at 18:44
-
@redwards510 yes, I get the same error until `project.fragment.lock.json` appears in directory. My current workaround is call MSBuild on xproj file, which generates this file, and then use dotnet publish that runs witohut errors. But your post was very helpful: for example, I tried to work with 3.5 RC1 but had `CommandAttribute` error, so I used 3.4.4 which worked – Alex Zhukovskiy Sep 20 '16 at 12:01
-
As of today, the cli at https://www.microsoft.com/net/core#windows is old. https://github.com/dotnet/cli/issues/3237 – Billy Oct 06 '16 at 23:57
-
Thank you @redwards510 Do you know how to have Octopus Deploy get this package from TeamCity instead of pushing to Octopus's nuget feed? – Billy Oct 07 '16 at 00:02
-
@Billy Sorry, I don't. We usually do it that way too. In this case I could only get it to work by pushing the zip to Octopus. I think that was because of the limited functionality of the tooling. – redwards510 Oct 10 '16 at 20:43
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.

- 28,177
- 5
- 87
- 103
-
1Victor, is there some info on Sake\KoreBuild tools somewhere? Why did you choose Sake? – Shrike May 25 '15 at 09:42
-
Is this the way you are supposed to use this today in 2016? I was looking into the build.cmd and it's trying to use KoreBuild from nuget packages. That package doesn't exist today. Any idea on how to build this? – Erlis Vidal Jan 13 '16 at 16:42
-
KoreBuild (or KoreBuild-dotnet) are not the official way to create build automations. They are just Microsoft internal packages that we happen to push publicly. While not officially supported, you are free to use them. The package is only available on the myget feeds and not on nuget – Victor Hurdugaci Jan 13 '16 at 16:59
-
@PWKad we still use the same build system as 1 year ago. We still use TeamCity and invoke the `build.cmd`/`build.sh` file. The build files in the dev branch are for `dotnet` which is RC2. For RC1 you have to use the files from the RC1 tag. Is there something in particular that didn't work in your scenario? – Victor Hurdugaci Mar 23 '16 at 06:35
-
At the moment you can try to use TeamCity plugin for .NET Core projects: https://github.com/JetBrains/teamcity-dotnet-plugin

- 373
- 4
- 10
Please check these blog posts;
http://blog.coderinserepeat.com/2015/01/25/building-asp-net-5-projects-in-teamcity/
http://blog.maartenballiauw.be/post/2014/12/19/Building-future-NET-projects-is-quite-pleasant.aspx

- 1,082
- 11
- 19
-
1Well the blog post links are like more than a year old. What can I say other than maybe "please check the date of a blog post and try to find a recent information before you spend 5 hours depending on it?" Especially if you're going to use it in production. – detay Mar 25 '16 at 11:40
-
Right the problem is there is no new information that I can find. Sorry I was pretty frustrated the other day. I will remove my comments and down vote for now but it is still in need of a better way. – PW Kad Mar 25 '16 at 13:27
Since there has been many changes to the ASP.NET Core world and I got asked about it a few times, I wrote down a step-by-step guide on how to setup a CI/CD environment using TeamCity for .NET Core. I think it is especially helpful for beginners.

- 158
- 1
- 1
- 13