How to exclude a .NET 5.0 project from build depending on the OS - visual-studio

We have a Visual Studio solution with several .NET 5.0 projects, one of which is a Windows Application (TargetFramework is net5.0-windows). It obviously fails to build on Linux and Mac. How can we make it so that it would build or not build, depending on the OS? The scenarios we need to support are:
Building from Visual Studio on Windows.
Building from JetBrains Rider on Windows and Mac.
Building from command line on Windows, Mac and Linux. For command line we currently use dotnet build, as well as dotnet test and dotnet pack which build the solution first.

Related

Xamarin.forms project in Mac terminal without Visual Studio

I'm trying to build a job for Xamarin.forms project in mac terminal without UI method. but, not sure which are the tools are mandatory to be installed. Could anyone help here ?
Installed : Dotnet Core 6 version of visual studio SDK
Build need to be fully in terminal(mac-command line)
Need to do without visual studio application
Why not try build the app from the command line using MSBuild and see what errors it gives you. That way, you can find out what's missing and add things until it builds.
I'm using this command to build my apps from Windows (you may need to change a few things on Mac):
"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\msbuild.exe" C:\Projects\MyApp\src\MyApp\MyApp.iOS\MyApp.iOS.csproj /p:Platform=iPhone /p:BuildIpa=true /p:IpaPackageDir=C:\Projects\MyApp\artifacts\App_iOS /p:IpaPackageName=MyApp.ipa /p:ServerAddress=192.168.0.23 /p:ServerUser="Username" /p:ServerPassword=123456SafePassword /p:ContinueOnDisconnected=false /p:Configuration=Release /restore /target:Build /verbosity:Normal
Here's some useful info on Continuous Integration with Xamarin.

MSBuild + Qt Vs Tool failed to include Qt on Jenkins

I am not able to build a Qt application using MSBUILD and Qt VS Tools on Jenkins.
I have created a dummy Qt application using Visual Studio (new project -> Qt -> Qt Widget Application) (https://github.com/ThomArmax/dummy-qtvstool260-test-app) which I can build and run on my desktop. But I can make it build on my Jenkins server.
Context
Visual Studio 2017 15.9.14
Qt 5.12.8 msvc2017 64 bits
Qt VS tools 2.6.0
Here is my Jenkins build script
set QTDIR=%QTMSVC2017_64%
%MSBUILD_VS2017% /t:rebuild /p:Platform=x64 /p:Configuration=Release QtWidgetsApplication1.sln
And the build output
dummy-qtvstool260-test-app\qtwidgetsapplication1\stdafx.h(1): fatal error C1083:'QtWidgets.h: No such file or directory
I have tried with different Qt version. Of course, I can manually add the necessary include paths, but I guess that should not be necessary. More over, it does not guaranty that I won't have other issues. I suspect a Qt Vs Tool issue.
I have also tried to define the QtMsBuild env variable to %LOCALAPPDATA%\QtMsBuild without success.
Does any of you guys had the same issue ?
Thanks by advance
Ok, I have figured out why. Fist, on the server, the QtMsBuild was not updated ... Then we used the amd64 version of MSBUILD, if I use the 32 bits version, it works fine !
See https://bugreports.qt.io/browse/QTVSADDINBUG-828

Visual Studio not recognizing installed Core SDKs

I have three versions of .NET Core installed on my machine:
However, both VS2017 and VS 2019 return the following error when I execute dotnet --version command:
PM> dotnet --version
dotnet : Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
I can create a solution targeting .NET Core but when I create a Console App targeting .NET Core, for example, the Debug button is labeled Attach instead of Start as usual, and Start Debugging and Start Without Debugging commands in the Debug menu are disabled.
What I tried so far:
Added "C:\ProgramFiles\dotnet" to system PATH variable.
Modified VS2019 using VS Installer.
Restarted several times.
I did have several other version of .NET Core but uninstalled them since I had no solutions targeting these versions and wanted to clean up.
I only left 2.2.300 and 3.0.100 and when I used VS Installer to modify VS2019 it added SDK 2.1.700.
Any ideas on how to resolve this issue without completely removing Visual Studio and installing from scratch?
Apparently x86 version(s) of .NET Core SDKs must be installed as well. After installing 3.0.100 x86 dotnet --version command works fine and I can build and debug .NET Core projects...

How to build a Xamarin DLL in visual studio from the command line?

Xamarin Studio has been replaced for Visual Studio on MacOS. I have a project that builds a DLL using Xamarin iOS. For DevOps (automated release), I want to build the project for release from the command line. I know previously the mdtool was used for this purpose, as seen in this answer but now in visual studio there is no more mdtools binary anymore.
msbuild has replaced mdtool (and xbuild), so all the tasks that once were handled by mdtool are now handled by the cross-platform msbuild and its standard set of cmd-line options.
Release configuration:
Clean a single project in a solution
msbuild /p:SolutionDir=./ /target:Clean /p:Configuration=Release SomeProjectLibrary/SomeProjectLibrary.csproj
Build a single project in a solution
msbuild /p:SolutionDir=./ /target:Build /p:Configuration=Release SomeProjectLibrary/SomeProjectLibrary.csproj
Note: Using Using SolutionDir=./ so these cmds are being run from the root directory of the solution.

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