Building a net40 project in VisualStudio 2022 - .net-4.0

A Windows update trashed my computer so I've had to reinstall from scratch.
We have some projects that multi-target net40
<TargetFrameworks>net40;net6.0</TargetFrameworks>
which were building just fine (and they build in the Azure pipeline) but now I can't get them to build locally.
My old machine was originally win10 with VisualStudio 2017, 2019, and 2022, but so far on the rebuilt machine I only have 2022.
The projects won't build, saying
error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
I guess this means I have to install an SDK pack?
I've tried 4.6.2 and 4.6.1 which are available through the VisualStudio installer, and 4.5 (NDP452-KB2901951-x86-x64-DevPack.exe from https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net452-developer-pack-offline-installer) which is not, and Windows SDK for Windows 7 and .NET Framework 4 from https://developer.microsoft.com/en-gb/windows/downloads/sdk-archive/
but still no joy.
Any idea what I need to do to get it to build again?

The solution seems to be to install VisualStudio2017 with net40.

Related

Visual Studio 2022 does not find reference assemblies for >NETframework Version 4.0

Trying to compile Python Django project but receiving build error:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Done building project "myFinancialTracker.pyproj" -- FAILED.
How can I resolve?
I also got the same error as you, this is because VS 2022 doesn't come with
.net framework 4.0 option during installation, to overcome this problem I install VS 2019 and enable the usage of .net-framework 4.0 during installation. After the installation, I tried to run my project again using VS2022 and the error goes away.
I tried to download and install .net-framework 4.0 separately but Microsoft doesn't allow me to do so, to overcome this, I install VS2019 instead.

Brand new CLR Class Library project won't build: missing MSCOREE.lib

Using the latest Visual Studio 2019 version, a brand new project will not build:
fatal error LNK1104: cannot open file 'MSCOREE.lib'
I have tried to re-install Visual Studio but that didn't change anything unfortunately.
These components have been selected by the installer but apparently it's not enough:
MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.24)
Windows 10 SDK (10.0.18362.0)
C++/CLI support for v142 build tools (14.24)
Question:
Are there any tricks to get CLR Class Library (.NET Framework) projects to build ?
Here is the solution:
Apparently, no matter what framework version you will target, the $(NETFXKitsDir)Lib\um\x86 macro will always point to C:\Program Files (x86)\Windows Kits\NETFXSDK\4.7.2\lib\um\x86.
Now here's the problem, even though you install 4.7.2 SDK in Visual Studio Installer, this file is nowhere to be seen.
But if you download .NET Framework 4.7.2 Developer Pack Offline Installer and press the Repair button, it gets correctly installed and a brand new project will build succesfully.
Alternatively:
Re-installing VS also fixes the issue ...

Cannot load project using .NET Core after installing Visual Studio 2019 version 16.4

I have installed the community Visual Studio 2019 version 16.4.
and clone the solution of .NET Core 3.0 but no project loaded something wrong in the SDK.
I have installed the SDK and runtime for 3.0 and 3.1, but still can not load any project.
You could fix the VS 2019 issue with the below steps
Run dotnet --list-sdks to know the exact version of the SDK installed
Modify the global.json file in the root folder of the project (For example,the project was showing 3.0.100 but you had 3.0.101 installed, you need to edit the same to point to that version and you could be able to reload the projects.
References:
https://learn.microsoft.com/en-us/dotnet/core/versions/selection#the-sdk-uses-the-latest-installed-version
https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#globaljson-and-the-net-core-cli
I had the same problem after I uninstalled Visual Studio 2022 Preview. Removing the C:\Program Files (x86)\dotnet\ directory from my PATH variable solved it.

VS2012 RTM missing .net 4.5 and mvc project templates

On Windows 8 RTM and just installed Vs2012 Ultimate RTM, I'm unable to create a .net 4.5 project nor a .net 4 or 4.5 ASP.NET MVC project. I've done a repair of VS2012, which did not fix it. Is there something obvious I'm doing wrong?
I also had the same problem..
Doing the following procedure solved it.
Copy the folder \packages\WPT from the visual studio 2012 installer CD to your desktop.
Uninstall the following in this order..
aspnetmvc4vs11tools.msi
aspnetmvc4.msi
aspnetmvc3vs11tools.msi
aspnetmvc3.msi
Then install these in this order.
aspnetmvc3.msi
aspnetmvc3vs11tools.msi
aspnetmvc4.msi
aspnetmvc4vs11tools.msi
Trying to repair didn't fix the problem. You have to remove and install these..
Hope this will help...
Your install is probably corrupted. VS 2012 needs .net 4.5 to run, so something has gone wrong if it's not available.
I would try uninstalling and reinstalling. It's brute force but it generally works.
You probably do not have the Windows 8.1 SDK installed. Visual Studio 2012, nor its updates, link the .NET Framwork 4.5 libraries for development.
Windows 8.1 SDK
You don't have to install the full SDK if you are just looking for the option to build web apps, just the .NET Framework 4.5.1 option in the installer. The full install is about 1.1GB, but just the .NET installer is only 72MB.
For those reading this that have not updated their copy of Visual Studio 2012, make sure you also have these installed:
Visual Studio 2012 Update 4
ASP.NET and Web Tools 2013.1 for Visual Studio 2012
Hope this helps!
Change .net framework version to 4.5

Targeting .NET 4.0 in VS 2012 on Windows 8

I just installed VS 2012 Ultimate RTM on Windows 8 Pro RTM and tried to open a solution containing several projects (class libraries and WinForms) targeting .NET 4.0.
When the solution is loaded, VS prompts that .NET 4.0 isn't supported. It gives me the chance to update my projects to 4.5 (and promises that I could change the target later) or install a "Multi targeting pack" for 4.0 from this page.
I decided to update my projects to 4.5 because I had no luck installing the offered Multi targeting pack (errors see below).
Unfortunately, VS does not show 4.0 as a target by default (when changing the target for an updated project), but redirects me to the page where I can download the Multi targeting pack.
So far so good, but I wasn't able to install any of the offered downloads (neither runtime nor targeting pack) again.
The error message says in case of .NET Framework 4.0.3 Targeting Pack:
Setup has detected that this computer does not meet the requirements to install this software. The following blocking issues must be resolved before you can install KB2600213 software package.
Installation Requirements:
Microsoft .NET Framework 4 Multi-Targeting Pack was not found. Please repair your installation for Microsoft Visual Studio 2010 in order to get this update.
Strange enough since I have no VS2010 installed.
.NET Framework 4.0.3 Runtime Installation stops with the following error:
KB2600211 does not apply, or is blocked by another condition on your computer.
I've checked that .NET 4.0 is installed (using the .NET Installation verification tool), I've tried to repair VS2012 but nothing let me target .NET 4 and the Event log does not contain any related reports. Any suggestions or hints (besides going back to Win7/VS2010)?
I'm honestly not sure what's going on. I have VS 2012 Ultimate RTM and all versions of .NET are supported.
I'm almost positive I never installed any .NET frameworks manually, though I did install Visual Studio 2010 Express for Windows Phone from http://create.msdn.com.