.NET projects

.net

#1

Is Circle CI having the ability to deal with .NET projects ?

If yes, Could you tell me how ?
If no, why doesn’t it support the .Net ?


Support for .NET
#2

Hello,

We do not officially support .NET

Some users have had luck with the mono framework which you can install via circle.yml

Another interesting idea would be to try running .NET inside of docker.


#3

Now its clear that circleCI does not support .NET builds. May I know the reason ?


#4

.NET is a Windows technology, and CircleCi is running on Linux machines.

The only way to build .NET is to try using mono or docker, as mentioned above.

Since building Windows projects on Linux machines tends to be somewhat tricky, it’s not something CircleCi has chosen to support at this time.


#5

OK, Understood.
Thank you so much for the reply.


#6

Now that .NET Core 1 (which runs on Linux) is released, will this change?


#7

While I would have to defer to CircleCi staff to see if they plan on changing their support policy, I have confirmed that the sample project at https://www.microsoft.com/net/core#ubuntu works flawlessly under CircleCi…


#8

Hi @drazisil. Thanks for confirming this. Out of interest, how did you get this working? I managed to get something up and running with the following circle.yml file:

dependencies:
  pre:
    - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
    - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    - sudo apt-get update
    - sudo apt-get install dotnet-dev-1.0.0-preview2-003121
  override:
    - dotnet restore
test:
  override:
    - dotnet test ./UnitTest/

Note that you have to set your build environment settings to use Ubuntu 14.04 for this to work.

I’d be interested to know if @drazisil found a simpler way to do this?

Also, it would be good to hear from Circle staff if there are plans to support this out-of-the-box in the future?


#9

Sure,

Build url: https://circleci.com/gh/drazisil/fun-with-circle/193
circle.yml: https://github.com/drazisil/fun-with-circle/blob/testing-dotnet-core/circle.yml

I hadn’t checked, but yes, this project is set to Ubuntu 14.04

It looks like you ran the unit tests, something I forgot. Otherwise it looks almost exactly the same :slight_smile:


#10

I have a problem with your circle.yml, using Ubuntu 14.04.

Failed to resolve library symbol hostfxr_load, error: /usr/share/dotnet/host/fxr/1.0.1/libhostfxr.so: undefined symbol: hostfxr_load
Failed to resolve library symbol hostfxr_unload, error: /usr/share/dotnet/host/fxr/1.0.1/libhostfxr.so: undefined symbol: hostfxr_unload
This executable relies on newer functionality (exports) provided by 'libhostfxr.so'
  - Updating 'libhostfxr.so' to version '1.0.2-beta-000581-00' might help resolve this problem.

I have copied too the following circle.yml, but the problem persists.

general:
artifacts:
- “hwapp”

dependencies:
pre:
- sudo sh -c ‘echo “deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main” > /etc/apt/sources.list.d/dotnetdev.list’
- sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
- sudo apt-get update
- sudo apt-get install dotnet-dev-1.0.0-preview2-003121

test:
pre:
- mkdir hwapp
- cd hwapp
- dotnet new
override:
- dotnet restore
- dotnet run
- echo “done”


#11

The error message you are getting mentions updating libhostfxr to a specific version. Try adding - sudo apt-get install dotnet-hostfxr-1.0.2-beta-000581-00 to your circle.yml file after - sudo apt-get install dotnet-dev-1.0.0-preview2-003121. Hope that helps!


#12

Perfect!
It’s resolved my problem.


#13

FWIW, I set up a project using this config now, which seems to work quite well. The build takes about 2 minutes once the NuGet packages have been cached (the 2nd build):

general:

dependencies:
  pre:
    - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
    - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    - sudo apt-get update
    - sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177
  override:
    - dotnet restore
  cache_directories:
    - ~/.nuget

test:
  override:
    - dotnet build

#14

Now it’s also possible to use docker images with the official ms built and runtime images to built .net core apps.
Use microsoft/aspnetcore-build to build the project and microsoft/aspnetcore to host / run it.

Some further reading regarding this : Exploring ASP.NET Core with Docker in both Linux and Windows Containers


#15

I am also looking into options to use Circle Ci with .NET apps but older .NET versions so no .Net Core. As far as I can see Circle Ci 2.0 supports custom Docker images. There is now also a Windows Server Core edition docker image available which supports .NET 3.5 and 4.x


#16

It is fairly easy to create a working build w/CircleCI 2.0, since it is pretty much just a modified Dockerfile.

version: 2
jobs:
  build:
    docker:
      - image: microsoft/dotnet:2-sdk
      
    working_directory: ~/repo

    steps:
      - checkout

      - run:
          name: NUnit Tests
          command: dotnet test MyProject.Test

My problem is what do I use for nuget cache key? Since I would need to hash all the .sln & .csproj files.


#17