Home How to Build .NET Core Solutions on AppVeyor
Post
Cancel

How to Build .NET Core Solutions on AppVeyor

I have recently upgraded #SNMP Library to .NET Core. And to the extreme, I get rid of the classic class library projects, and use a single .NET Standard 1.3 class library instead. Then it becomes a challenge to build the code base on AppVeyor, so I think it is worth the while to document what I have changed.

The Whole Manifest

The whole manifest can be found here, https://github.com/lextudio/sharpsnmplib/blob/8e1d5b7e99a9d91c20d0dccc2d339afeacd809a3/appveyor.yml

The Image

It is very important to use Visual Studio 2017 image. It has all the development dependencies installed (Xamarin, .NET Core SDK, as well as Git and NuGet bits).

Build Script

You cannot use the default MSBuild tasks from AppVeyor, so I suggest you use a custom script like I do.

If your solution only contains .NET Core projects or .NET Framework projects, you can now even use dotnet command to perform the operations,

1
2
3
dotnet restore somesolution.sln
dotnet clean somesolution.sln
dotnet build somesolution.sln

But due to some unknown reason (I think it is a bug), currently you cannot do so if the solution contains Xamarin projects. You might hit error messages similar to this,

1
2
3
dotnet restore SharpSnmpLib.NetStandard.sln
C:\Users\lextm\Downloads\sharpsnmplib\SharpSnmpLib\SharpSnmpLib.iOS.csproj(55,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.3\Xamarin\iOS\Xamarin.iOS.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\lextm\Downloads\sharpsnmplib\SharpSnmpLib\SharpSnmpLib.Android.csproj(61,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.3\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

An easy workaround is available, which I use here,

1
2
3
msbuild /t:Restore somesolution.sln
msbuild /t:Clean somesolution.sln
msbuild somesolution.sln

Test Script

The default AppVeyor unit test runner configuration does not yet support .NET Core runners. Thus, again we have to use a custom script right now.

I simply use dotnet test as it is the easiest.

Hope this post saves you some time.

This post is licensed under CC BY 4.0 by the author.
Advertisement

Which Class Library Project to Go in Visual Studio 2015/2017/2019

Plan for #SNMP Library vNext

Comments powered by Disqus.