Roslyn for .Net 4.7.2 [duplicate] - c#

This question already has answers here:
Installing a .NetStandard 2.0 Nuget package into a VS2015 Net 4.6.1 project
(2 answers)
Closed 3 years ago.
I am so confused.. I am trying to install a nuget package that has a dependency on .NetStandard v2.0, after reading this post about it, it made sense to me that I could run any library that is dependent on .NetStandard 2.0 with .Net 4.7.2. Unfortunately, while trying to install a nuget package, it fails, saying it is not compatible with .net 4.7.2.
I am mainly trying to add the new Roslyn libraries Microsft.CodeAnalysis and if you look at the dependencies it says it supports .Net 4.7.2, the issue seems to stem from another dll its dependent on Microsoft.CodeAnalysis.CSharp.Workspaces, as that says it only has a dependency on .NetStandard 2.0. (but really .Net 4.7.2 can run .NetStandard 2.0)
Does anyone know if this is possible or will I be needing to move to .net core framework to be able to support a project like this?
Really it should say it only has a dependency on .NetStandard 2.0 but be able to get installed onto a target framework with 4.7.2 or .Net Core
Edit:
Using Visual Studio 2015 and C#6.
Its a rehosted windows workflow designer application (working on c# compilation/intellisense for inputs to the designer)

Thanks to #IanKemp for finding an answer that helped me, I will flag this post as a duplicate but I wanted to first post a step-by-step fix for future developers that may come across this.
So I downloaded the latest Nuget version (VS 2015 VSIX - latest v3.6.0) here
Then I tried to update to the latest Roslyn package via NuGet package mananger and got this error message:
The message points you to this link, that will download the .Net Standard Build Support extension: https://aka.ms/netstandard-build-support-netfx
I then tried to update to the latest Roslyn package and it all worked!!
Happy coding all.

Related

How do I configure VS 2022 with .NET Framework 6.0?

I've searched the interwebs for a solution to this to no avail. I cannot for the life of me discover how to make a .NET 6.0 project in VS 2022. The weird part is when I go to the installer, the runtime for 6.0 is selected as installed. I cannot find an SDK option in the installer's list of packages however. I have installed the SDK for 6.0 and it shows as present when I check "dotnet --info." However, whenever I go to VS to create a project the latest version of .NET listed is 4.8.
Thanks!!
the project you build is targeting . Net Framework, which latest version is 4.8. For the .Net 6 you mentioned is more likely .Net Core6.0. Please refer to the related link:.Net Framework

Converting a project from .NET5 to .NET Framework 4.8

Long story, summarized...
I started working on a solution creating many projects (like class libraries) for the solution. Then I ended up needing to use a third-party SDK for something I had an expensive license for. Come to find out, that third-party SDK only supported .NET Framework.
Because my solution was based in .NET 5/Core and the SDK in .NET Framework I had a big issue. They can not exist in the same environment and reference each other. So, on to biting the bullet and spending hours converting all my projects to .NET Framework 4.8 while singing a neverending song of curse words...
The Issue
My first class library I'm trying to convert from .NET5 to .NET 4.8 happens to have a Nuget package installed. That Nuget is Newtonsoft.Json Version="12.0.3" (https://www.nuget.org/packages/Newtonsoft.Json).
After changing the framework in the project file, VSCode is telling me the Newtonsoft namespace can not be found. This makes me think that the Nuget I have installed is not compatible with .NET Framework 4.8.
The issue I was running into was the namespace Newtonsoft could not be found after changing the framework from net5.0 to net48.
The issue was OmniSharp that was giving a false positive. I restarted VSCode and the issue went away once VSCode loaded with the new framework being used.
.NET supports cross platform targeting which means you can have your SDK style .NET5 project multi-targets both net5 and net48. In future, if the third-party library targets .NET Core then you can simply change the TargetFrameworks property.
A similar issue has been discussed here https://github.com/dotnet/runtime/discussions/40304 incase if that helps.

Is MonoDeveloper from Unity 2018.3.12f1 (latest) supporting .NET Framework 4.7.2?

This question is not a duplicate
I am scripting in Unity using C# with the build in MonoDeveloper-Tool.
When I run the script I got the error message, that the assemblys for framework ".netframework, version=v4.7.1" has not been found. I looked it up on stackoverflow and only found this article:
The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found
So I downloaded this version, but I can't install it, because I already have the latest version installed from .net framework, which is currently .NET Framework 4.7.2
Questions:
Is MonoDeveloper in "Unity 2018.3.12f1 Personal" not supporting this version?
Are there ways to upgrade it to make it work?
Or do I have to remove the .net-version, that I have and get an older one to make it work?
The message you are getting is ususally related to scripting backend setting in PlayerPreferences.
Here's a screenshot from 2017
and from 2019
It defaults to 3.5 for new projects, and you need to manually set it to 4.x, than pretty much all features from 4.7 work fine
Is MonoDeveloper in "Unity 2018.3.12f1 Personal" not supporting this version?
MonoDeveloper supports, but Unity doesn't.
Are there ways to upgrade it to make it work?
Try install .net 4.6 with Visual Studio Installer or upgrade the Unity.

Targeting .NET Framework 4.6.1 in Xamarin project

When I create a new Xamarin.Forms project in Visual Studio 2017, in the project properties I can't target any other framework than
.NET standard 1.0
.NET standard 1.1
.NET standard 1.2
.NET standard 1.3
.NET standard 1.4
.NET standard 1.5
.NET standard 1.6
.NET standard 2.0
I'm trying to use a nuget package targeting .NET Framework 4.6.1 and it doesn't load because of that.
I have a warning when i add that package :
The package CHU.Xamarin.Helpers 1.0.0.1 has been restored using '.NETFramework,Version=v4.6.1' instead of target framework of the project '.NETStandard,Version=v2.0'. The package might not be totally compatible with your project.
Is there a way to target .NET Framework 4.6.1 in the project ?
If i add the nuget package anyway, i've got an error saying it is not compatible with monoandroid71 :
The package CHU.Xamarin.Helpers 1.0.0.1 is not compatible with monoandroid71 (MonoAndroid,Version=v7.1). The package CHU.Xamarin.Helpers 1.0.0.1 handles : net (.NETFramework,Version=v0.0)
The error messages are translated from French so might differs from english counterpart
NOTE: None of the following answers "how to target .NET Framework 4.6.1 for a Xamarin.Forms project". If you really, truly, need to know how to do that, and know what you are doing, and why, then search elsewhere - doing so is an advanced topic, and is no longer recommended. For cross-platform projects, stick with a .NET Standard version.
In this case, despite the question title, doing so is not the solution. Keep reading for more details.
I'm trying to use a nuget package targeting .NET Framework 4.6.1 and it doesn't load because of that.
Actually, it does load. It gives you a warning. You can probably ignore that Framework vs Standard warning - I've been ignoring a Framework 4.6.1 vs Standard 2.0 warning for over a year, without problem.
error .. saying it is not compatible with monoandroid71
This is the real problem that is stopping you.
Is there a packages.config file? If so, open it in a text editor, and search for monoandroid71. If present, then yes, this is the problem -
The packages.config mechanism contains an outdated "hint", OR you ARE targeting an older Android version, that is not compatible with the nuget you wish to use - as the message says.
Possible fix:
Target Android 8.0 or higher. In your Android project (e.g. if you named your Xamarin Forms project "App1", look in solution for the project labeled "App1.Android") / Properties / Application / Compile using Android version (Target Framework) / select Oreo or Pie.
Update all nugets to latest.
If packages.config still mentions monoandroid71, then you have outdated "hints".
Different ways to fix outdated hints in project.config. Do ONE of the following:
Rt-click on project.config in Solution pane, select "Migrate to PackageReferences". This newer mechanism doesn't rely on hints.
OR Delete project.config. Add the nugets again.
OR Manually edit project.config. Change all targetframework=monoandroidXX to be the same - whatever the highest number you find in the file. Probably monoandroid81 or monoandroid90.
OR Start all over. Latest VS 2017 version OR VS 2019. Either works fine for this purpose. New project / C# / Mobile App Xamarin Forms. Copy your source files (.cs, .xaml) to the new projects - DON'T use your old .csproj or package.config. The goal is to use all the latest build options, including PackageReferences.

Change the .net framework with visual studios 2013 and the xamarin plug in

I am trying to change the .net framework for a android c# app in visual studios 2013. I tried to create a new project with .net framework 4.0 but I still get an error saying that my application is targeting the 4.5 framework. Does anyone know how to force this? The reason I am doing this is that I have a nuget package that uses the 4.0 framework, however if there is a way to get that nuget package to use the 4.5 framework that is an equally valid solution.
You cannot change the .net framework for an Android app. It will always be targeting MonoAndroid.
You cannot use a NuGet package that only assemblies for the .NET framework since they may use parts of the Xamarin Android API that is not supported.
So you are left with finding another NuGet package that supports Android projects or re-compiling the source code in an Android library project so it targets MonoAndroid, which may or may not work depending on what the source code does.

Categories

Resources