Closed ttSpace closed 2 years ago
Can't seem to repro this on my machine, I never see this error. I was able to repro it on the test VM provided by the CTI team. However, the test VM is win11 while my machine is win10. Going to try to repro on my own win11 VM to verify.
One difference that I noticed with my local win10 install is there are some .NET Framework targeting packs installed that are not installed on the CTI test machine (visible through the Visual Studio Installer -> Individual Components). This is the likely culprit, but I will verify on my win11 VM.
For example, my machine shows this:
The CTI machine does not have these targeting packs installed. Not sure why, as I don't remember installing these manually.
I will verify on my win11 vm, as that's a clean install.
I suspect this is due to Python .targets importing SDK targets. Grep for <Import
in BuildTasks/*.targets to see where it does that.
My clean win10 vm repros this as well.
@int19h Question for you - instead of going down this rabbit hole, should we just make the pyproj target a more recent version of the .net framework? 4.0 is very very old and is no longer supported. What do you think?
It is unclear to me how we end up there, though. Python project templates and their associated .targets don't actually target .NET specifically. The project templates do request MSBuild version to be 4.0 via <Project ToolsVersion="4.0">
- but this appears to say that this attribute is disregarded by current MSBuild versions anyway?
Yeah I tried moving that version up to 4.8 but it made no difference. Guess we have to dig in :(
Hi everyone. I have a brand new install of Visual Studio 2022, and am trying to follow this tutorial: https://docs.microsoft.com/en-us/visualstudio/python/tutorial-working-with-python-in-visual-studio-step-01-create-project?view=vs-2022
But I am getting the exact error described here. I only created a new Python Application, and this error appears immediately:
Severity Code Description Project File Line Suppression State Error 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 PythonOne C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 1217
Any update on this?
Hi @dhbusch2 , this is a known issue. It shouldn't be preventing anyone from running or debugging python scripts, but I know it's ugly. It's in our backlog to fix 😄
I just ran into this issue also. I recently upgraded to windows 11 and a fresh everything. When I pulled my repo (that was previously being developed on VS 2017 and windows 10) and try to run I get the error mentioned.
However, if I make a completely fresh python django project in VS 2022 it runs just fine. I can't find a difference in any of the project files that would cause this though. What should I do to get my repo working?
I'm pretty sure this is an issue with the PTVS build and should have nothing to do with your projects. We haven't been able to dig into this yet, but we'll most likely take a look sometime in January.
ah didnt realize I ended up on a specific subsection when following links around to track down this issue sorry about that. Hopefully whatever you guys have to fix for your project will point me in the right direction. Not being able to find any setting/config files that are different between my "imported" and brand new projects yet having different results is mightily infuriating.
Is your existing repo a Django project as well?
yup. Am I just being dumb and not looking at the right spots? the .pyproj files and .sln files are virtually the same other then a few GUIDs and file references.
Can you please share or link to the two pyproj files? If one repros and one doesn't, that would definitely help with our investigation 😄
OK I put a zip here with them. pyprojfiles.zip doesntworkatall.pyproj is the old one I am trying to get working. Get that error when hitting run or build etc. runsbutrebuilderrors.pyproj is the new one. And when verifying things before uploading for you, I noticed that it runs fine and builds fine. But if I do a rebuild on it it fails with the 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 "DjangoWebProject1.pyproj" -- FAILED.
Thank you! One last question - the build error is annoying and we're certainly going to fix it. But can you still run the program? In all cases I've seen this error, it hasn't prevented the user from running. I just want to make sure that's also the case here.
No I can't run the program at all for the doesntworkatall.pyproj file. Just hitting run generates the error. Running DOES work on the new django project I made.
Ok thank you so much for the repro and the extra information. It sounds like this is more severe than previously indicated. We have some internal tasks that unfortunately have higher priority, but we will look at this as soon as we can :)
I can repro in today's build 17.1.0 Preview 3.0 [32030.14.main]
.
I did some digging on this bug and the root cause is as follows: The pyproj files we generate don't specify a .net target framework, so it uses some global default which is v4.0. 4.0 is not supported in VS2022, which is why the error is being shown.
So the fix is just to target a newer (supported) framework in our python tools targets file. This is fixed locally and will be released in the future.
If you don't want to wait for the fix, you can implement the same change in your pyproj file, as a workaround. Put this in your pyproj, then re-open the VS solution and the error should go away.
<PropertyGroup>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkMoniker>.NETFramework,Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
</PropertyGroup>
Hi.
Will this fix in Visual Studio 2022 also apply to SQL Server Database Projects files (ie. sqlproj)?
When building on the command line, the following error occurs:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1220,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 [c:\agent_work\1\s\MySolution\src\MyDatabaseProject\MyDatabaseProject.sqlproj]
When opening the project in Visual Studio 2022 17.1.0, the following message appears:
The SQL Server project MyDatabaseProject targets .NET Framework 4.0, which is no longer supported.
After adding the following properties to the project file, Visual Studio is able to load the project:
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
Thank you.
Hi Rami,
This fix was implemented in a targets file specifically for python tools, since this bug was reported for PTVS. I believe there is a bug open somewhere for it to be fixed globally in visual studio, but I'm not sure where that is or what the status of that is. Global VS bugs tend to take longer to fix and roll out, since they usually involve more discussion and oversight. Individual product teams are a bit more agile in that sense.
In the meantime, I would suggest reporting a problem (feedback) from within visual studio and specify that a sqlproj is experiencing this problem (and maybe include a link to this issue) so the sql team can address this in their product.
I just did a fresh install of Windows 10 and VS 2022. I have scope studio projects that are hitting this .NET 4.0 error. I have never hit this before on my other device in VS 2022. What can I do to fix this?
I'm not sure what scope studio projects are, this repo is for Python Tools in Visual Studio. This issue has been fixed for PTVS.
In any case, see my comment for a workaround that might work for whatever else you are using 😄
Installed the latest dotnet 6.0.300 in mac. But, while trying to run dotnet test, it throws : : 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.
I have finally found a solution to this problem!
If for any reason you are still using .NET Framework version for which there is no SDK, then here is my solution to the problem.
This problem is solved by directly downloading the package via NuGet. We go to https://www.nuget.org/ and we are looking for Microsoft.NET.Framework.Reference.Assemblies
, select the desired version and download the package directly.
Now open .nupkg file as archive, go to /build/.NETFramework/
and unpacking folder with version in this funny path C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
(If the folder with the current version already exists, just delete it). Should look like this:
Everything should work now!
==================================================================================
If you somehow keep a project that uses .NET Framework 2.0 or 3.0 or 3.5, here is the following solution for you!
Open start, type "Windows Features" and check .NET Framework 3.5 (includes .NET 2.0 and 3.0).
IT IS NECESSARY THAT WINDOWS UPDATES ARE ENABLED OTHERWISE IT WILL NOT WORK
==================================================================================
Hello. Why this issue is closed? It is not fixed at all. I'm currently struggling with SSRS project. It builds perfectly in VS 2022 with this extension: https://marketplace.visualstudio.com/items?itemName=ProBITools.MicrosoftReportProjectsforVisualStudio2022, but fails with Version=v4.0 were not found
error in CI/CLI. Build somehow works in VS but still doesn't work in CI even using latest VS 2022. I guess there should be any parity between VS/MSBuild builds, no? Why do they behave different? Are any magic CLI parameters for them to work same?
@FixRM This issue was for python projects specifically. The issue is fixed in the targets file for PTVS. I'm not sure about SSRS projects.
In any case, please see my root cause comment (https://github.com/microsoft/PTVS/issues/6747#issuecomment-1015704916) for a workaround. You should be able to pass in the TargetFrameworkVersion
property on the command line (using /p:TargetFrameworkVersion=xxxxx
or something similar).
And no, msbuild and VS are not exactly the same. :) If you want more a more detailed log of steps that ran, try specifying a binary log path with the /bl:pathToFile
CLI argument, then you can open the binary log using the MSBuild Log Viewer
Thanks, @AdamYoblick. It worked
I'm getting an error during "Build" time. could someone suggest solution.
""""""""""""Severity Code Description Project File Line Suppression State Error 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 [AEITagDecoding""""""""""""""""""""]
Thank you
Describe the bug
Steps to Reproduce
Create a Python Application project.
Expected behavior
It should be created successfully without any errors.
Additional context and screenshots
An error appears in the error list.
Installation details