Running NUnit tests written in C# with Jenkins on Linux - c#

Is it possible to run tests (written in C# with NUnit) with Jenkins on Linux OS?
I can find a lot of info on running NUnit tests with Jenkins but can't find any speak of my situation.
UPDATE
Looks like it's possible. I'll need to use a Master Jenkins in Linux to run a Slave Jenkins in Windows. Described in the article.

Looks like it's possible. I'll need to use a Master Jenkins in Linux to run a Slave Jenkins in Windows. Described in the article.

This turned out to be relatively painless using mono on Linux
1) Install NUnit Console.
sudo apt-get install monodevelop-nunit
2) Under Build in your Jenkins project "Add build step" "Execute shell" after your MSBuild step
cd "$WORKSPACE"
# so nunit does not fail on file operations
export MONO_IOMAP=all
nunit-console ./UnitTests/UnitTests.csproj
The only problem I ran into were failing tests involving NancyFx due to Nancy trying to access the projects bin/Debug directory. (The project runs normally with mono under the same environment setup) This turned out not to be a problem as we moved away from Nancy.

Related

Is it possible to debug a C# console application using git bash?

I am using Visual Studio Community 2022, and I was wondering if you could use another CLI to run/debug a c# console application. (I can't use cmd.exe or powershell because it's blocked by the admins of the device I'm using). Git Bash would be preferred, because it's already installed. Thank you!
Edit: Looks like you can't do this. dotnet run just tries to open the blocked binary, no matter where you run it. I think the admins hate everyone though because they allow you to install lots of things (like Unity, vscode, etc.) but running anything just doesn't work.
Thanks for trying everyone!
use this to run your program in CLI but you cannot debug it if you want to debug use debugger mode of vs2022,
If it's a framework-dependent application (the default), you run it by dotnet yourapp.dll.
Run the project in the current directory:
dotnet run
check Microsoft Docs dotnet run for more options.
CLI: Use Vs2022 Terminal in View->Terminal it may help You to run it.

Dotnet build behaves differently when executed from TeamCity

We're seeing a Lucene.NET analyzer build warning that shouldn't be there when executing dotnet build for one of our ASP.NET Core 3.1 web apps. The strange thing is that this warning seems to happen only when executed with the .NET runner in TeamCity; it (correctly) doesn't happen when running the dotnet build command directly from a PowerShell runner, or from the PowerShell console on the same machine (with the same user account, same folder, same code).
The build warning is actually due to a bug (that was fixed in a later Lucene.NET version) but the point is that we see different behavior.
We have tried running the exact same command that's displayed in the Build Log, including passing the TeamCity-generated RSP file to it. Still, outside of the .NET runner we can't reproduce the warning. We confirmed that the same user account runs the process, uses the same NuGet cache and dotnet.exe (and .NET SDK), runs in the same folder for the same code, with the same parameters.
The only thing we can think of is that somehow the .NET Plugin executes dotnet build differently but in a way that's invisible from the Build Log. However, we are out of ideas what else to try or investigate.
Could you help pinpoint where the difference in the two builds could be? Thank you in advance!
I've previously asked this on the TeamCity forum but didn't get a reply.
We ended up just running dotnet build directly, not using the .NET Runner. It has also cut certain builds' times down drastically (40-50% where there were a lot of build warnings).

How to publish my WPF solution with Rider?

I cannot seem to deploy my WPF app using the Rider IDE. Most support tell me to use the "Publish" button in VS which of course doesn't really help me.
I do produce an executable with the .NET Project and .NET Executable build Configurations, but it doesn't seem to run on any other machine, where it seems to close immediately without spitting error messages (even from PowerShell)
N.B. the app launches fine from my own machine, and from anywhere I choose to move it to.
I've tried to set Edit Configurations... > Runtime arguments: to
dotnet publish -c Release -r win10-x64
as suggested in this post, but that wasn't enough.
Running dotnet publish -c Release -r win10-x64 .\my_app.csproj from PowerShell returns
error MSB4216: Impossible to execute the task "GenerateResource"
[...]
Failed to connect to "CLR4" runtime and the "x86" architecture.
Make sure that
(1) The necessary runtime and/or architecture is present on the machine
(2) "C:\Program Files\dotnet\sdk\<version>\MSBuild.exe" exists and
has permissions to execute.
Now MSBuild is missing from that folder, but there is MSBuild.dll there.
Am I really missing a fool-proof easy way of publishing a C# WPF solution with Rider?
I use https://wixtoolset.org/ to publish my apps. It's free and independent of the IDE...

Building C# project using jenkins

First of all, im not sure if there is a specific forum thats more suitable for request about Jenkins, but I figured I just post it here.
So, I have this C# project, it right now requires Visual Studio 2015 to build and I would like to automate builds with Jenkins. This is the first time I'm using Jenkins and I was able to set it all up, it fetches the code from the gitlab repository, but right now there is no build action configured. For "fun" i tried to simply make it use a "windows batchfile" as build file and added echo test. Checking the console output it downloads the repository code and then tries to execute the batchfile, result is:
java.io.IOException: Cannot run program "cmd" (in directory "/var/lib/jenkins/workspace/Project"): java.io.IOException: error=2, No such file or directory
This of course makes sense, but I wonder now, is there a way to build a C# project with jenkins on a debian server without resorting to mono or something? I know that people build C++ projects for windows with Jenkins on a linux root, so there has to be some sort of cross compiling possibilities.
If the Visual Studio 2015 is a dealbreaker I can also strap it down to VS13 or even below. Any help is greatly appreciated!
/EDIT
Its probably important to say that Mono is NOT an option. Im using features like WPF that are not available for Mono.
Use Jenkins' MSBuild plugin.
Jenkins.NET is a good blog about using Jenkins in a .NET environment. First post is here.

Developing c# project with linux server

The school has given us an ubuntu server to use for an svn repository, trac, and building automated processes. The people in my group are all using visual stuido to develop the project.
Right now the server is setup to use ant as the builder and auto reports junit and javadocs to the apache webserver for easy viewing on the web.
My question is, how do I setup the server to do the same thing but for a c# project.
What I have done is install mono on the server. Now I am looking into nant to replace ant on the server but I am struggling to come up with a script to run with the post-commit hook.
From my understanding, we will develop in visual studio and commit through svn and then nant will execute when post-commit hook is called by the svn server.
I also found nunit to replace junit for testing purposes.
Sorry for the random thoughts but basically I am looking for advice/suggestions on how the setup the server for the project. am I headed in the right direction?
Run NAnt through mono or run XBuild (similar to MSBuild). post-commit hooks are ok for very light things, but look at Jenkins or TeamCity or travis-ci.org or AppVeyor or AppHarbor for anything major. Even better, git publish to Azure Web Apps with a free DreamSpark account, and it'll build and deploy on a post-commit hook.

Categories