MSTest for C# project targeting .Net version 5? - mstest

I have a .Net desktop project that targets .net V5. I added a MSTest project to write some tests but the highest version of .Net that I can target seems to be 4.8. How do I target .net 5.0 on my testing project? My project that I need to test references .Net 5.

You need to add a .net core test project.
.net 5.0 is not .net framework. Since you added a framework project, it only allows you to choose up to 4.8 which is the latest .net framework version.
You can find a guide for the console version creation here: create test project
Or follow the visual studio guide

Related

Newly installed .NET version doesn't show up in target frameworks

I want do develop a console app for .NET Framework 4.72
I installed the .NET Framework 4.7.2 developer pack.
I restarted the system, opened Visual Studio to create a new project but the :NET Framework 4.7.2 doesn't show up in the target framework options.
What step am I missing?

.NET Upgrade Assistant upgrading a library built with .NET Framework 4.6.1 to netstandard2.0

I have a .NET Framework 4.6.1 project. I'm following instructions on this .NET Upgrade Assistant Page to upgrade to .NET 6.0. After I completed the upgrade, I looked at the project file. The Upgrade tool upgraded the v4.6.1 to netstandard2.0.
Shouldn't the project be upgraded to .NET 6.0 and not netstandard2.0? Is it not possible to upgrade to .NET 6.0 from .NET Framework 4.6.1.
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
to
<TargetFramework>netstandard2.0</TargetFramework>
You can find some solution on this link:
Migrate from .net standard to .net 6 using the upgrade tool
Already answered.
But based on my understanding. If you update a class library then the assist tool will change your project to netstandard.
After that I think you are able to change it via the csproj to .net6.

Unable to set .net core 3.1 to Blazor Webassembly client and shared projects

I installed Visual Studio 2019 Community 16.6.1 (the latest update) at B:\Program Files (x86)\Microsoft Visual Studio\2019\Community on a Windows 10 x64 bit.
Afterwards, I also installed dotnet-sdk-3.1.300-win-x64.exe with its default path C:\Program Files\dotnet. They are in different drives.
I create new Blazor Webassembly projects consisting of
ProjectName.Server with target framework set to .net core 3.1 by default.
ProjectName.Shared with target framework set to .net core 2.1 by default.
ProjectName.Client with target framework set to .net core 2.1 by default.
I attempted to change the last two projects above to .net core 3.1 but the target framework dropdown does not provide me with .net core 3.1 option.
Question
Why is there no .net core 3.1 option available to choose? What is wrong?
ProjectName.Shared and ProjectName.Client are .Net Standart and that is not .Net Core

Compiling .net standard project on Team City

What is needed to compile a .net standard (1.0) project on an Team City agent. Is there an SDK for .net Standard?
I know that there is an SDK for .net core, but I want to build a .net standard project that has nothing to do with .net core.
Please don't answer with: "install Visual Studio" ;-)
Thanks in advance.
The same SDK that can build .NET Core Applications can also be used to build .NET Standard libraries.
The ".NET Core SDK" is a distribution of a .NET Core based MSBuild version, the MSBuild assets needed to build .NET "sdk-based" project files, a version of NuGet and the .net CLI which provides commands like dotnet build. On windows, it can even build .NET Framework applications (with some limitations).
Alternatively, you can use the version of MSBuild that Visual Studio or Mono 5 include (mono 5 just can't create nupkgs from library projects at the moment).
.NET standard is a subset of .NET Core. To build any .NET core or .NET standard application you need to install the CLI tools on your TeamCity agent. You can get them here: https://www.microsoft.com/net/core#windowscmd
Or you can use Chocolatey to install them:
choco install dotnetcore-sdk

Using VS2005 assemblies in VS2010 projects

I have a number of assemblies which were built with VS2005 (.Net 2.0). I would like to reference them in a VS2010 project. Do they need to be rebuilt in VS2010 to execute in the .Net 4.0 framework or will they continue to execute in the .Net 2.0 Framework?
Your .NET 2.0 assemblies will continue to work fine when referenced from a .NET 4.0 project in Visual Studio 2010.
This assumes that you have both .NET 2.0 and .NET 4.0 frameworks installed on the machines where your application will run. (.NET 4.0 framework is brand new from the "ground up" whereas the like of .NET 3.0 and 3.5 were "additive").
By default, your pre-built assemblies will continue to reference the .NET 2.0 framework (i.e mscorlib.dll etc.) whilst your new Visual Studio 2010 will reference the .NET 4.0 framework versions. See the screen-grab from reflector below:
(VS2005Test is a class library built against .NET 2.0 in VS2005, and TestReferencingVS2005.exe is a console application built against .NET 4.0 in Visual Studio 2010)
Visual Studio 2010 also supports "multi-targeting" with projects at the source code level. This means that you can load the source for a project that was written in VS 2005 and targets the .NET 2.0 framework, and VS2010 will allow that project to continue to target the 2.0 framework. Of course, you can also upgrade it to use 4.0.
So, if you don't mind re-building, and it's not going to cause you problems, you can use Visual Studio 2010 have both your assemblies and final application all targeting .NET 2.0 or "upgrade" the assemblies to .NET 4.0 along with your application.

Resources