Having a frustrating issue with something on my windows 10 PC updating my DotNet SDK version from 6.0.102 to 6.0.103. This is a problem as one of the software projects I work on is the hard locked to certain SDK versions.
Does visual studio code automatically update this or is it something else? Either way it would be good to know a way to turn it off.
Visual Studio Code does not update .NET SDK version in your system, since it is a pure code editor with extension support and does not mess up with other components and applications in the computer.
However, these can update your .NET SDK version:
Updating Visual Studio: Unlike VSCode, Visual Studio manages other components in the computer and may update .NET SDK version as you update Visual Studio.
Microsoft Update: .NET Runtime and SDK installations may be updated automatically via Microsoft Update if you use Windows and this switch is On in your Windows Update Advanced Settings:
Fixing SDK Version
There is a way to fix which SDK version is used by the compiler by adding a global.json file on the project or solution directory with the correct SDK version:
{
"sdk": {
"version": "6.0.102"
}
}
If you add the file in the root directory, the file will be taken into consideration for all projects in that directory and also in sub-directories. With this method, you can still use older SDK versions if they exists in your system.
For more info: Select the .NET version to use
.NET SDK Versioning
.NET SDK uses a special versioning. According to that, there should be no difference between version 6.0.102 and 6.0.103 other than bugfixes. Therefore, it would be a nice idea to reconsider the SDK version coupling even in patch versions such as the example versions you provided.
For more info: Overview of how .NET is versioned
Related
I've installed the preview of .NetCore 3.0 and tried to run the blazor template Blazor (ASP.NET Core hosted) in Visual Studio 2019:
The error that occured, was the following:
NETSDK1045 The current .NET SDK does not support .NET Core 3.0 as a target. Either target .NET Core 2.2 or lower, or use a .NET SDK version that supports .NET Core 3.0.
During these days I had to overcome this issue on a number of different development machines/containers: eventually, I found no less than 6 different reasons that could cause this kind of error:
Missing .NET Core 3 SDK (x86 or x64)
.NET Core SDK preview support not enabled in VS2019
VS2017 instead of VS2019
Wrong SDK path in PATH environment variable(s)
Wrong SDK path in MSBuildSDKsPath environment variable(s)
Wrong SDK version in the project's global.json file
The workarounds for those scenarios are pretty easy to understand, you basically have to either install the proper SDK or remove the "offending" SDK reference(s). However, I did my best to document them all in this post on my blog.
Following this comment, I managed to resolve the problem by installing the x86 version of the .NET Core 3.0 additionally to the x64 version. The build worked after restarting Visual Studio (2019).
for me the solution was removing a path variable MSBuildSDKsPath - Because of exploring preview sdks's i at some point declared that variable to fix another sdk bug - seems like that force sets the used version. So in my case it was set to 3.0.100 and resulted in errors when attempting to use 3.1.300
I got the same error and resolve it with checking the option "Use previews of the .NET Core SDK (requires restart)".
Open Tools > Options and try looking at "Preview Features" or ".Net Core" depending of your Visual Studio version.
Watch out of VS updates, they can disable it.
This is a very hacky-feeling solution but at least it worked. Let's say you've installed the SDK for 3.0.100-rc1-014190. It shows up in dotnet --list-sdks as expected but still doesn't seem to be detected by Visual Studio, and you get the same NETSDK1405 error when trying to build or test anything from the dotnet CLI.
Look in your dotnet SDK install directory (usually C:\Program Files\dotnet\sdk). You should see your preview SDK in there. Either create a copy or rename the existing folder to remove the preview version suffix. For example 3.0.100-rc1-014190 would instead become 3.0.100, like so:
Doing this made .Net Core 3 preview support finally work in VS2019 Preview 4 and the dotnet CLI for me.
For me it was as simple as enabling the preview in Visual Studio 2019. Unfortunately most posts that show how to do this are I believe out of date. I finally came across this stack overflow post How to enable .NET Core 3 preview SDK in VS2019? They moved the check box and it was not on by default for me.
This was a frustrating issue to track down and after doing all of the updates to VS and still not being able to install I tracked it down to an environment variable. Try removing MSBuildSDKsPath and see if that fixes your issue.
I have installed VS2019 on the E: drive of my machine rather than the smaller c: boot drive. I had it installed before I Wiped the machine on the c: drive and it took up WAY to much space. Now It gives me this error message AND WILL NOT allow me to pick any targeting .NET Framework on C# WFA before 4. I have NO Idea what to do, Ive followed the advice and went to the website listed and manually downloaded the .NET Core SDK for 2.0 and installed it, then tried to repair it, and it JUST KEEPS SAYING ITS NOT INSTALLED, the project needs .net 2.0 to work. Am I gonna have to wipe the WHOLE computer again and take up ALL the space on my boot drive to get this damn thing to work? I just don't understand, It does this on enterprise & community, how the hell can Microsoft NOT excpect an ENTERPRISE to install VS 2019 ON another drive then the boot drive, ESPECIALLY WHEN ALL THE TOOLS YOU NEED ARE GARGANTUAN.
IVE TRIED EVERYTHING THE ERROR MESSAGE SAYS. there are 2 options it gives to load the project, 1. DOWNLOAD the sdk manually for .NET FRAMEWORK 2.0 WHICH IVE INSTALLED AND REPAIRED, 2. CHANGE THE PROJECT TO .NET 4.0, WHICH I CANNOT DO. or the worst option JUST CLOSE THE SOLUTION
I want to be clear that I Have another machine that this project pulls up perfectly with VS 2019 and I know people are gonna jump to the Microsoft doesn't support something that old bandwagon. It gives me the option to target .NET Framework 2.0 on the other machine RIGHT NOW, and did on this one for VS 2019 Community AND ENTERPRISE BEFORE INSTALLING ON AN OTHER THAN BOOT DRIVE, so wheteher they TECHNICALLY SUPPORT IT IN ALL THE DOCUMENTATION IS A VOID ARGUMENT, it worked perfectly before on this exact machine, and does an another one with VS 2019, if it was a support issue I seriously doub MS would give an error messae saying to install .net 2.0, I knew installing CORE probably wouldn't work, but that's the websit it sent me to.The point is they DID just 2 days ago, Microsoft randomly stops supporting legacy features like that on an ENTE#RPRISE PRODUCT with NO warning after release? Now I see why a lot of c++ people DESPISE VS.
If something in your project absolutely requires the .NET framework 2.0, try installing it from https://www.microsoft.com/en-us/download/details.aspx?id=19988 (this is NOT .NET Core)
Visual Studio 2019 doesn’t support older .NET Framework versions than 3.5, see documentation. If you really need .NET 2.0 you need to install an older Visual Studio that has support for that version.
.NET Core is completely different thing than .NET Framework 2.0 so installing that doesn’t help.
This has nothing to do with where you install applications.
Also note that support for 2.0 has ended a decade ago so if this project is needed it would be highly recommended to update it into a newer version. There usually aren’t many reasons why this cannot be done.
Fixed it for anyone that EVER has this problem again, you've got to search through some deprecated websties but im absolutely sure If you've made it this far you can figure out how to install the .net faramework 2.0 sdk if you just search hard enough lol
I've installed the preview of .NetCore 3.0 and tried to run the blazor template Blazor (ASP.NET Core hosted) in Visual Studio 2019:
The error that occured, was the following:
NETSDK1045 The current .NET SDK does not support .NET Core 3.0 as a target. Either target .NET Core 2.2 or lower, or use a .NET SDK version that supports .NET Core 3.0.
During these days I had to overcome this issue on a number of different development machines/containers: eventually, I found no less than 6 different reasons that could cause this kind of error:
Missing .NET Core 3 SDK (x86 or x64)
.NET Core SDK preview support not enabled in VS2019
VS2017 instead of VS2019
Wrong SDK path in PATH environment variable(s)
Wrong SDK path in MSBuildSDKsPath environment variable(s)
Wrong SDK version in the project's global.json file
The workarounds for those scenarios are pretty easy to understand, you basically have to either install the proper SDK or remove the "offending" SDK reference(s). However, I did my best to document them all in this post on my blog.
Following this comment, I managed to resolve the problem by installing the x86 version of the .NET Core 3.0 additionally to the x64 version. The build worked after restarting Visual Studio (2019).
for me the solution was removing a path variable MSBuildSDKsPath - Because of exploring preview sdks's i at some point declared that variable to fix another sdk bug - seems like that force sets the used version. So in my case it was set to 3.0.100 and resulted in errors when attempting to use 3.1.300
I got the same error and resolve it with checking the option "Use previews of the .NET Core SDK (requires restart)".
Open Tools > Options and try looking at "Preview Features" or ".Net Core" depending of your Visual Studio version.
Watch out of VS updates, they can disable it.
This is a very hacky-feeling solution but at least it worked. Let's say you've installed the SDK for 3.0.100-rc1-014190. It shows up in dotnet --list-sdks as expected but still doesn't seem to be detected by Visual Studio, and you get the same NETSDK1405 error when trying to build or test anything from the dotnet CLI.
Look in your dotnet SDK install directory (usually C:\Program Files\dotnet\sdk). You should see your preview SDK in there. Either create a copy or rename the existing folder to remove the preview version suffix. For example 3.0.100-rc1-014190 would instead become 3.0.100, like so:
Doing this made .Net Core 3 preview support finally work in VS2019 Preview 4 and the dotnet CLI for me.
For me it was as simple as enabling the preview in Visual Studio 2019. Unfortunately most posts that show how to do this are I believe out of date. I finally came across this stack overflow post How to enable .NET Core 3 preview SDK in VS2019? They moved the check box and it was not on by default for me.
This was a frustrating issue to track down and after doing all of the updates to VS and still not being able to install I tracked it down to an environment variable. Try removing MSBuildSDKsPath and see if that fixes your issue.
According to a reply by someone apparently from Microsoft in this answer it seems it's an SDK and he says I can use the 16299 Desktop Extensions version for targeting a 14393 machine.
On the other hand, in Visual Studio, it's added as a reference, which seems to indicate that it's a runtime executable that exists on the target computer and therefore I would need to target either 16299 or 14393, but not both.
I think it's more likely that it is an SDK, because if not - we wouldn't be able to target multiple versions of Windows 10 with one app (unless every version of the OS contains the older "runtimes" as well). But I haven't been able to find any source saying this explicitly.
So: Do I need to target the version on the target machine, or can I target the latest version?
It's an extension SDK to the Universal Windows Platform SDK. For your desktop extension SDK you want to pick the same version that you are using for your UWP SDK reference, e.g. if you are using Windows SDK 16299, use the desktop extension SDK 16299. Adding such a reference adds a reference to .winmd files, which contain the metadata for the API surface (those are not runtimes). There is only one UWP runtime on your machine (the one that came with the OS installation).
You can still use the 16299 SDK to build apps that target 14393. See this topic for versioning considerations, and the concepts of minversion, targetversion and version adaptive code:
https://learn.microsoft.com/en-us/windows/uwp/updates-and-versions/choose-a-uwp-version
I am writing a custom installer in C#.
Can you tell me an easy way to check if the machine has .NET version installed [even 2.0].
In cases where it is not installed, my app doesn't even start.
Thanks
MSDN has a blog post with sample code to detect if .NET 3 is installed.
[Edit: As mentioned by Stephen Clearly, the author of the blog post also released a tool that can be easily wrapped in a custom installer (and supports all .NET versions)]
Otherwise:
You could always use the file system and check in the %systemroot%\Microsoft.NET\Framework folder.
This will tell you if the following release versions of .NET are installed
v3.5
v3.0
v2.0.50727
v1.1.4322
v1.0.3705
I don't know what is your custom installer, but you could use a Setup and Deployment Project in Visual Studio where you can define .NET Framework launch condition.