How to run xUnit tests targeting new .NET Core *.csproj in Teamcity? - 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

Related

Azure Pipelines setup issues with .NET5 Specflow NUnit Project

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.

Visual Studio Build Not Deploying Upon Build

I am trying to do a Visual Studio Build on TFS 2017. So far, it seems to do the build, but will not do the standard Publish/Deploy I am used to on my local file system, with the Precompiled WCF app, etc. This is what I have so far attached as images, and the PublishProfile I have switched to in desperation. They have VS 2017 installed on the build server, and have updated the MS Build to the latest version. Please help! :)
Visual Studio Build
VM Deploy XML
Check the build log to see whether the deployment executed.
Run the MSBuild command locally on the build agent machine to see whether it works.
Try the following arguments:
/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish

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.

Build Visual Studio 2003 solution or .NET 1.1 projects with psake

Unfortunately, I have mixed .NET version projects. Some legacy code is in .NET 1.1 and other is in .NET 3.5. I cannot use
exec { msbuild test.sln }
because msbuild does not support compiling .NET 1.1 solution.
How can I build .NET 1.1 solutions with psake? I think psake is cool and want to utilise it.
On command prompt, I can do
.\devenv.com /rebuild release "c:\engine.sln"
But I can't figure out how I do the same thing within psake build file.
If
.\devenv.com /rebuild release "c:\engine.sln"
is what you do, all you have to do is either make sure devenv is in PATH or supply the full path and do:
exec { devenv.com /rebuild release "c:\engine.sln"}

What do I need to install a Visual Studio 2010 (sln)-compatible Build Agent in TeamCity?

I seem to be unable to install a build agent on our TeamCity 5.1.2 build server that is compatible with a VS2010 (sln) build configuration.
Under "Build Runners", the following runners are listed:
Ant: Runner for Ant build.xml files
Duplicates finder (.NET): C# and VB duplicate code finder
Command Line: Simple command execution
And under "Compatible configurations", the project I've configured to build with the Visual Studio 2010 (sln) build runner is listed under "Incompatible configurations".
To install the build agent, I'm simply running the .msi installation package, but it seems the default settings are not good enough. The build server machine has Visual Web Developer Express 2010 as well as .NET versions 2.0-4.0 installed, but no full version of VS. Do I need anything more?
(I have no experience whatsoever of building with msbuild scripts, so if I can I want to avoid having to do that.)
I think I figured it out:
Install the Windows SDK from Microsoft. Right now, the latest version is 7.1.
Note that since I just suddenly noticed that it worked, I don't know for certain that this is what did it - it might me completely irrelevant, but this is the only thing in my configuration I changed that I think could be relevant.
TeamCity build agent does not detect .NET 4.0 Client Profile as dotNetFramework4.0. Check you have full .NET Framework 4.0 installed.
Another reason of that is build agent has corrupted plugins. To fix it:
- stop agent
- remove /plugins, /system, /tools folders
- start agent
- wait till agent autoupgrade (agent service may be shown as stopped, just wait)

Resources