I am considering which is the difference between tis two packages. If i will search in references of visual studio i will find System.Net.Http.dll version 4.0.
But if i will look into nuget packages i will find a version 4.3.4.
Both of them are work very nice. But which of two is better to use visual studio or from nuget?
Thank you
The version you are seeing in Visual Studio is predicated on the version you are running of .Net. Each version of .Net Core's SDK could potentially have a different version of System.Net.Http.dll. What you are seeing in Nuget is the latest version, which does not appear to match the version for your currently used .Net SDK.
Related
Months ago I had build a Windows app using a mix of C# and F# projects. The C# project uses FSharp.Core 5.0.0. I had not noticed this until today, but the .fsproj does not specify a version of FSharp.Core. This hasn't been an issue and successfully builds on my local machine using Visual Studio 2019 (all projects are using 5.0.0).
Today, a colleague of mine cloned the repo and tried building the project, only to get a build error for a detected package downgrade of FSharp.Core from 6.0.5 to 5.0.0. My colleague uses Visual Studio 2022 and noticed while the C# project was using FSharp.Core 5.0.0 (as explicitly specified in the .csproj), the F# projects were using 6.0.5.
I've done a bit of reading with what I could find for FSharp.Core implicit references, but don't really understand how the version is selected or how to remedy this situation.
How does Visual Studio figure out which version of FSharp.Core it wants to use for FSharp projects and how can I insure uniform behavior on different machines and versions of Visual Studio.
FSharp.Core is defined in the F# targets loaded by build tooling. It's pinned to the latest released version for the .NET SDK you're using.
You can ready here about using it with C# projects: https://github.com/dotnet/fsharp/blob/main/docs/fsharp-core-notes.md#c-projects-referencing-f-projects-may-need-to-pin-fsharpcore
I am working on a project on TFS. This project was created on someone else's PC on VS 2017 and the newest .NET framework and published to Azure.
I got the project on my PC, I have VS 2015 and I had to change the .NET framework of the project to 4.6. Everything was fine, I could make changes to the project and commit.
But when I tried to publish to Azure from my PC, I got a very unclear error:
Publish Failed
Connecting to ...
Looking for solutions online, I had to downgrade the version of the package Microsoft.Net.Compilers from 2.6.1 to 2.4.0 . And that worked !
I turned off my PC. Next day when I opened the project and ran it, I got this error locally :
Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.6.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I tried to uninstall Microsoft.ApplicationInsights and reinstall it with version 2.6.1 , but it says i need a newer version of nuget.
I am not sure how to proceed from here. I already installed all the updates in my Tools -> Extensions -> Updates but nothing changed.
Why are all these things happening to my project and how can i fix it?
PS: upgrading my VS to 2017 is currently not an option due to many exterior reasons.
Thank you.
I've gotten that error locally as well and was actually able to resolve by manually adding the file to my project folder, may be worth a shot.
Downgrading .NET Framework causing packages issues
Just like Hans said nuget packages change quite rapidly, which often require the latest version NuGet. Some new features in the package only supported by the newer NuGet (like PackageReference) or some issues fixed on the newer version. For example, install package Microsoft.EntityFrameworkCore.SqlServer 2.1.1 on Visual Studio 2015, which requires NuGet client version '3.6.0' or above.
So, the workaround for this issue is create a new project with Visual Studio 2015, copy the code from previous projects, then add those nuget package one by one to find out the reason why it needs the newer version nuget.
However, I want to talk more over about this question is that the best way to resolve this issue is to install Visual Studio 2017 alongside Visual Studio 2015. As we known, using a lower version of the Visual Studio and .net framework to open a higher version of the Visual Studio and .net framework is not recommended, it will always bring a lot of incompatibility errors and some other weird issues. Since upgrade your Visual Studio to 2017 is currently not an option due to many exterior reasons, so I suggest that you can install Visual Studio 2017 alongside Visual Studio 2015. Besides, developing the same project with different versions of Visual Studio and submitting it to the TFS server may bring many unpredictable risks.
Hope this helps.
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.)
To use the new C# 7.1 language features with Visual Studio 2017, you add the setting <LangVersion>latest</LangVersion> to your project file(s).
However, building such projects from MSBuild (version 15.3.409.57025, located at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin) results in an error:
CSC : error CS1617: Invalid option 'latest' for /langversion;
must be ISO-1, ISO-2, Default or an integer in range 1 to 6.
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
This covers 200+ projects that were originally created variously in Visual Studio 2013 and 2015. They were all re-targeted to .NET 4.7 using the Target Framework Migrator tool (which saved lots of clicking and appears - based on inspecting .csproj file changes - to do the job correctly).
The projects all build successfully from Visual Studio 2017.
Nuget packages
Microsoft.Net.Compilers nuget package does not work and needn't to be installed.
Set the following project/build settings
Set at least C# 7.1 or higher in the Debug and Release build properties. (via: Project menu > [ProjectName] Properties > Build tab > [Advanced] button > Language Version).
Setting it to latest does not work.
Also make sure that you are running the latest MSBuild version.
Add a reference to the Microsoft.Net.Compilers package (version 2.3.x, to get C# 7.1).
A short description of the package:
Microsoft.Net.Compilers
This package not only includes the C# and
Visual Basic compilers, it also modifies MSBuild targets so that the
included compiler versions are used rather than any system-installed
versions. Once installed, this package requires Microsoft Build Tools
2015.
Make sure you have changed for "All Configuration" and not just "Debug"
else you will be baffling why it is failing at production.
In case you land here because you get the error as the OP mentioned, running msbuild via command line (e.g. from a build agent such as jenkins), the solution may be as easy as to upgrade Microsoft Build Tools 2015.
You can do that via choco install microsoft-build-tools or manually via the official Microsoft Build Tools 2015 or by updating your Visual Studio 2017 installation.
I've got a solution with a C# console app using C# 7.1 here.
Using the VS 2017 command line (and thus MSBuild 15.3.409.57025) it worked fine. (The .csproj does contain <LangVersion>latest</LangVersion>.)
Is this feature just not yet supported by MSBuild, or is it possible to get this working?
Yes it is.
Which instance of csc.exe is being run and what's its version? Because it looks like, despite quoting the version, you have the wrong version of csc.exe (the error message says 1-6 so not even C# 7 would work).
We discovered that our MVC projects were triggering this issue.
To fix, we updated the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package used by these projects from version 1.0.0 to 1.0.7.
Visual Studio 2017 (15.x) supports C# 7, but what about Visual Studio 2015 (14.x)?
How can I use C# 7 with it?
You can replace the compiler shipped with Visual Studio for a C# 7-enabled version by installing the Nuget package Microsoft.Net.Compilers:
Referencing this package will cause the project to be built using the
specific version of the C# and Visual Basic compilers contained in the
package, as opposed to any system installed version.
There is no indication that I can see on the package page as to whether this is officially supported in Visual Studio 2015. My not-thorough tests so far indicate that it works but not painlessly - C# 7 code compiles, but is underlined with the red squiggly line which indicates a syntax error:
Note that you will also need to install the Nuget package System.ValueTuple to use the new C# 7 value tuples features.
In my case, installing just Microsoft.Net.Compilers didn't work. Instead, I had to do the following:
Install Microsoft.CodeDom.Providers.DotNetCompilerPlatform for the project (Tools => NuGet Package Manager => Manage Nuget Packages for Solution...) and install Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Install the latest Microsoft.Net.Compilers for the project
Install any other NuGet package for the latest C# feature you want to use. In my case, my goal was to use Tuples, so I installed System.ValueTuple and worked fine.
But still note that C# codes which are not known by Visual Studio 2015 default compiler will still have red squiggles underneath.