Azure Pipelines setup issues with .NET5 Specflow NUnit Project - visual-studio

Having an issue setting up an Azure Pipeline with my .Net5 Specflow NUnit project.
Those the list off jobs I currently have set up however as you can see I am getting an error in the build:
##[error]C:\Program Files\dotnet\sdk\5.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): Error NETSDK1005: Assets file 'D:\a\1\s\obj\project.assets.json' doesn't have a target for 'net5.0'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project.
I have checked my project file and the reference to net5.0 is in there.

It looks like that you didn't install the .NET 5 SDK on the build agents. You can use the .NET core task (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer?view=azure-devops) to install it on your agent.
You should also update the NuGet client you are using in your pipeline. 4.4.1 is really old.

Related

Xamarin vstool build cannot find NuGet MSBuild targets

Background
I recently converted my Xamarin.Forms app from PCL to Net Standard format.
All of my projects now use PackageReference in the csproj file. Which means no more package.config or package.json.
We use TFS 2015 to build, sign, package our .ipa and .apk files. After conversion, the default MSBUILD build steps do not work as they look for mdtool and the new Visual Studio has vstool instead. So, I updated the build steps to use new tools via command line.
All my projects are NetStandard now (including iOS and Android).
Issue
I can successfully restore NuGet packages using restore MySolution.sln -force on Mac build server. But when I run vstool build MySolution.sln after that, I get this error:
error: NuGet packages need to be restored before building. NuGet
MSBuild targets are missing and are needed for building. The NuGet
MSBuild targets are generated when the NuGet packages are restored.
I am able to successfully run the nuget restore and vstool build locally on the build machine. But only when TFS runs the command via agent, it shows that error message.
Setup
Builds: TFS 2015 on Mac agent running Visual Studio 7.5
According to the error and your description, you need also check if your build agent has corresponding capability to support vsbuild.
Take a look at this related question MacOS - Visual Studio Support and give a try with this workaround:
As a work around we set the Xamarin.iOS variable manually in the build
agent and changed the mdtool path in the Xamarin iOS Build step to
"/Applications/Visual Studio.app/Contents/MacOS/vstool".
Besides you could also try to use the suggestion from Matt in the comment above.
Ok. I was finally able to get a successful iOS build on Mac server. This is the setup that works,
Using PackageReference in iOS .csproj
No package.config, project.json, or AssemblyInfo.cs file.
Running nuget restore .sln before building the iOS project.
Build solution using <path-to-vstool>\vstool build .sln -c:<configuration>
Now, I am working on the Windows machine for Android setup. Once I have that working, I will post my findings here.

Why am I getting "File type is not supported" on TeamCity 9 when using NUnit 3?

I'm using TeamCity Enterprise 9.1.5 (build 37377).
I have created a Build Configuration.
I have created an NUnit Build Step.
For NUnit Runner I selected NUnit 3.
For Path to NUnit Console Runner I entered: packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe
In my Visual Studio solution I have installed the NUnit.Runner package.
When I run the Build Configuration I get the following error in the logs:
File type is not supported
How do I get my NUnit tests to run in TeamCity?
What worked for me:
I uninstalled NUnit.Runner and installed the following packages:
NUnit.ConsoleRunner
NUnit.Extension.NUnitProjectLoader
NUnit.Extension.TeamCityEventListener (not sure if this is needed, or not)
Why is the error being generated?
The ConsoleRunner can't handle .nunit files. That ability is part of NUnit.Extension.NUnitProjectLoader. The directory that extension is in will need to be listed as part of the .addins file. (I can't find the GitHub links where I found that information.)
How I troubleshooted:
TeamCity generated an .nunit file. I copied that file from the agent to my development machine to troubleshoot and run nunit3-console.exe myself. Once it ran on my development machine, TeamCity worked, too.

Building UWP apps on VSTS fails with MSBuild

I'm trying to set up CI builds for a Xamarin app using VSTS. The solution builds fine locally but in VSTS its failing on the build task on the UWP app. The android project builds fine in VSTS. As mentioned, everything builds and runs fine locally.
The only error I can see is:
##[error]Process 'msbuild.exe' exited with code '-1'.
Which doesn't help me much, when I look through the rest of the log file, which can be found here (I cant post it here as it doesn't format correctly and is unreadable)
According to the error logs, you are building a UWP project which target to "15063" SDK on a Hosted Build Agent while the Win10 SDK installed on Hosted Agent is 14393 which cause the error.
2017-04-27T14:48:04.8813251Z Could not use a link to copy "C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.15063.0\Windows.winmd" to "C:\a\1\s\MyProject\MyProject\MyProject.UWP\obj\x86\release\ilc\in\WinMetadata\Windows.winmd". Copying the file instead. Unspecified error
2017-04-27T14:48:04.8822945Z
2017-04-27T14:48:04.8822945Z 'MyProject.UWP' violates pattern constraint of '\bms-resource:.{1,256}'
The workaround is deploying your own build agent and install 15063 SDK on it.

How to run xUnit tests targeting new .NET Core *.csproj in Teamcity?

I tried it with xUnit test runner 2 (actually 1.1.3). Unfortunately it doesn't support .NET Core and it works only with full .NET 4.5:
So TC agent cann't run the tests. I checked docs and found it to be outdated. I asked at official xUnit Slack server - no feedback thanks to #naile.
netcoreapp1.1 is used as the only project's target framework. Further details:
xUnit.net 2.2.0
Teamcity 10
VS2017
new *.csproj project format
We run xUnit tests for csproj based dotnet core stuff in TeamCity. It's no different than running them on your local machine (outside Visual Studio). Use the dotnet test runner, like so:
dotnet test project.csproj
I use that for projects targeting both netcoreapp1.1 and net46

unable to find nunit assembly for xamarin test cloud in VSTS

Hi I am using VSTS for CI. For my Xamarin Android application during the build process it is trying to test the app on cloud, it's failing as it is not able to find nunit.framework.dll file in the project. I am using Nunit Version 2.6.4
The NuGets in the project are included in the output directory but still, I am getting the issue, can you please help me with it?
VSTS: Test Assembly Directory: Solution/Droid.UITests
Error:
Unable to find the nunit.framework.dll in the assembly directory. In Xamarin Studio you may have to right-click on the nunit.framework reference and choose Local Copy for it to be included in the output directory.
I got it. I had to remove the old references from the solution's nuget package collection.

Resources