Visual Studio 2022 does not find reference assemblies for >NETframework Version 4.0 - .net-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.

Related

Building a net40 project in VisualStudio 2022

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.

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.

CMake: "cl.exe not able to compile a simple test program"

I want to build DCMTK in Visual Studio 2010.
I followed the advice here enter link description here, as the image shows.
And I still get the same error. Any ideas?
Run the following script before running cmake.
>vcvars32 (to set some system vars, C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat)
A similar problem has been reported here
The solution is:
First, check if you have .NET 4.5 on your system. If you do, that is very likely causing the problem. Try either upgrading to VS2010 SP1 or downgrade .NET to 4.0
CAUSES:
This error appear because you have installed Visual C++ 2012 after you have actually installed Visual C++ 2010 in your system; another cause is because .net Framework 4.5 replace .net Framework 4.0; .net Framework corrupted files;
HOW TO SOLVE:
Uninstall .NET Framework 4.5 from your system; then download .NET Framework 4.0 and install it; this should fix your problem;

WIX And NAnt : Unable to build WIX source code

I am trying my hands on source code of WIX 3.6 to debug something as well as learn something.
On executing make.bat (present in root folder of WIX source) file, first i got NAnt not found. So I downloaded NAnt and updated make.bat file. On executing the file again I am getting this error
NAnt 0.91 (Build 0.91.3881.0; alpha2; 8/17/2010)
Copyright (C) 2001-2010 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///D:/wix36-sources/wix.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: inc
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[property] Target framework changed to "Microsoft .NET Framework 2.0".
[property] Read-only property "dir.hhw" cannot be overwritten.
[property] Read-only property "hhw-found" cannot be overwritten.
BUILD FAILED - 2 non-fatal error(s), 2 warning(s)
D:\wix36-sources\wix.build(65,4):
Build file 'D:\wix36-sources\test\wixtests.build' does not exist.
I have .Net framework 4.0 installed on my local. Also I searched through registry for the registry key mentioned in the error and didn't found. Am I using right version of NAnt?
Do you have all of the prerequisites as described in the documentation?
In order to fully build WiX, you must have the following Frameworks and SDKs installed:
NAnt (0.90 or later)
The following components from the Windows SDK for Windows Server 2008 and .NET Framework 3.5, Visual Studio 2008, Microsoft Windows 7 SDK, and/or Visual Studio 2010:
x86 and x64 compilers, headers and libraries
IA64 headers and libraries are optional, but they are necessary for IA64 custom action support
If you want to be able to build optimized IA64 binaries, you'll need both the Windows SDK for Windows Server 2008 and .NET Framework 3.5 SDK AND Visual Studio 2008 installed; or the Microsoft Windows 7 SDK AND Visual Studio 2010.
HTML Help SDK 1.4 or higher [installed to Program Files or Program Files (x86)]
The missing registry key seems to be related to the VisualStudio SDK - you don't need this for basic WiX.
If you have all of the prerequisites, try passing the -debug switch to Nant for more detailed debugging output.
To solve this problem:
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
[readregistry] Registry Path Not Found! - key='Software\Microsoft\VisualStudio\VSIP\10.0\';hive='Microsoft.Win32.RegistryHive[]';
If you used Visual Studio 2010 SP1 you need Visual Studio 2010 SP1 SDK