Can I use "Roslyn" in Visual Studio 2017 with .NET 4.7? - c#

I've upgraded my project with scripting capabilities and also Microsoft.CodeAnalysis nuget and it downloaded hundred of dependent System.* packages. Before it was only Microsoft.CodeAnalysis.Common, CSharp, CSharp.Workspaces, etc. What is happening? Does it work in Visual Studio 2017 with .NET Framework 4.7? Or is it included in 4.7 (I didn't find it anywhere)? Should I wait?

Older versions of Microsoft.CodeAnalysis.Common only had a variant for .Net 4.5, with few dependencies.
But since version 1.3.0, the package also has a .Net Standard 1.3 variant, which has many dependencies, as is usual for .Net Standard 1.x packages. When installing such package into a project targeting .Net Framework 4.7, NuGet installs all the .Net Standard dependencies. As far as I know, there is nothing wrong with that and the project should work fine.

Related

C# 6, VS2015-3, .Net 4.6, System.Numerics.Vectors has no Vector<T>

I am upgrading an application from Visual Studio 2013 Net 4.5.1 to Visual Studio 2015 C#6 Net 4.6, and I would like to make use of the System.Numerics.Vectors Vector< T >. I have been using Vector4 already to get SIMD which works fine in my app, I would like to get Vector< T > support though and make full use of the larger AVX/AVX2 SIMD Registers.
The development system has Net 4.5, 4.51, 4.52, 4.6, 4.61 and 4.62 Multi-Target Packs and SDKs installed.
The project properties Target Framework is 4.6. I also tried 4.61.
The project references include both System.Numerics (4.6.81.0) and System.Numerics.Vectors (4.6.81.0).
But all that I get in the System.Numerics namespace is the BigInteger, Complex, Matrix3x2/4x4, Plane, Quaternion, Vector2/3/4.
I do not get Vector< T >.
At this late stage (2019) am I still supposed to install the old NuGet Preview packages to still get the Vector< T >? Is Vector< T > not by now a part of the current .Net 4.6 and 4.61 public releases?
And if I do have to use the old NuGet, is the NuGet package just the relevant information for VS and the JIT, or does that mean that I have to distribute another DLL even though System.Numerics.Vectors is already on the system...
I must be stupid...
Vector<T> is only in the .Net 2.1 standard preview, no it's not part of .Net Framework.
Applies to
.NET Core: 3.0 Preview 3 2.2 2.1 2.0 1.1 1.0
.NET Standard: 2.1 Preview
UWP: 10.0
Xamarin.Android: 7.1
Xamarin.iOS: 10.8
Xamarin.Mac: 3.0
Yes you will have to include the nuget, which will have its own Assembly
is the NuGet package just the relevant information for VS and the JIT
As far as I know there is no compiler magic and Vector<T>, it's just a vanilla struct, so what you are including are the definitions of this structure, this is all.

Can I target both .net standard2.0 and net471 in csproj file

I have a project that the target framework is .net standard 2.0, we use the System.Runtime.InteropServices.RuntimeInformation.OSDescription in our source code, but this library isn't support .net framwwork 4.6.1.Yesterday, one of our customer report a bug, about this question. his local framework is .net framework 4.6.1.
Can I set the target Framework to make a notice to user during they add the reference from Nuget Package?
And to make user to know if your local framework is 4.6.1, you should not use this version package and will cause bug.
When I set the target frameworks to:
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
<PropertyGroup/>
Then run dotnet build I get the error message:
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found.
To resolve this, install the SDK or Targeting Pack for this framework version
or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.
Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies.
Therefore your assembly may not be correctly targeted for the framework you intend.
Then I go to the office website to download .net framework 4.7.1 SDK, but I install fail.
The error message is
A .NET Framework 4.7.1 or higher update has been installed on this computer
So I am confused!
Here is my dotnet --info
It seems I make a joke, I download the .net framework 4.7.1 from .net framework 4.7.1, but I can't install it. However, when I use Visual Studio Installer to install .net framework 4.7.1. It's fine.
And now run dotnet build, It success. More confused am I, Why can't install it from .exe file.

Could not install NuGet package MPI.NET 1.3.0 in MS Visual Studio 2017

I am trying to install NuGet package MPI.NET 1.3.0 to MS Visual Studio 2017 C# project. I am getting the following error:
Could not install package 'MPI.NET 1.3.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I have tried to create C# projects in different versions of .NET Framework, but it would not install. On the official GitHub site for this package (MPI.NET GitHub repository) it is written that the package is updated for .NET 4.0. I have tried creating 4.0 and lower projects, but no success.
Help anyone?
Looking at the packages available on nuget.org, version 1.3.0 targets .NET 4.6.2, whereas version 1.2.0 targets .NET 4.0. So if you try to install version 1.2.0 of the package into your project, you should be okay. It sounds like the GitHub documentation needs to be updated to reflect this new reality.
(Personally I would bump the major version number for a change like this, given that it's not necessarily backwardly compatible for existing users, but semantic versioning is less cut and dried than it sometimes sounds.)

How to update to .NETStandard 2.0 NuGet Package

I've a good old .NET Framework 4.7 Class Library in Visual Studio 2015 currently using Microsoft.Extensions.Configuration NuGet package version 1.1.2. I'm trying to update this to version 2.0, but I'm getting this error:
Microsoft.Extensions.Configuration 2.0.0'. You are trying to install
this package into a project that targets '.NETFramework,Version=v4.7',
but the package does not contain any assembly references or content
files that are compatible with that framework. For more information,
contact the package author.
I see that the new version only supports .NETStandard 2.0. Do I have to convert all my project to either .NET Core or .NET Standard in Visual Studio 2017?
.NET Framework versions 4.6.1 and higher do support .NET Standard 2.0+, but only when using new tooling. Make sure you update to VS 2017 version 15.3.0 or higher and have the .NET Core SDK 2.0.0 installed and no global.json in your solution's directory hierarchy pinning a lower SDK version.
You may also need to install the .NET Core workload in VS 2017
Yes you have to convert your project to .Net standard 2.0 to use the Microsoft.Extensions.Configuration 2.0.0 package.
Check out the below link for .Net standard 2.0 supported .Net framework version
as of now the, .Net standard 2.0 supports only up to .Net framework 4.6.1
.Net standard 2.0 supported api

Two versions of System.Net.Http

I have difficulties to understand dual existence of System.Net.Http. It exists as a part of .Net Framework 4.7 (in version 4.0.0.0), but is also available as a separate package in much newer version (version 4.3.2 as of now).
Why is it available twofold?
Why latest available version (probably 4.3) has not been included in .Net Framework 4.7 when it was released?
First, package version and assembly version can be different versions.
Package System.Net.Http, version 4.3.2: Assembly version is 4.1.1.1
I can't find a released package for System.Net.Http with assembly version 4.0.0.0, so I think that it's not distributed as a package, but there is at least one prerelease package which has that assembly, System.Net.Http, version 4.0.0-beta-22416. It seems that all prerelease packages from version 4.0.0-beta-22416 to version 4.0.1-rc2-24027 have .NET Framework versions of the assembly, with version 4.0.0.0.
.NET Framework 4.7 supports the APIs that exist in System.Net.Http, Version=4.0.0.0 and if you want extra functionality, you can pull extra APIs by installing a newer package, like you would do with any other package.

Categories

Resources