Open walterlv opened 1 year ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Temporary workaround: remove <EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>
from your project.
@olgaark @nkolev92 as this looks related to package reference support in cppcli projects. Does msbuild -restore not correctly call nuget?
Got more details from @lukka offline. Specifying the individual project (msbuild /t:restore project.vcxproj
) or disabling package reference support should work around this for now. Full support should be coming in 17.7.
FYI - this is also affecting any .NET 6 C++ / CLR projects. All of the above hold true. setting
the error from VS2022 is error : Your project does not reference ".NETCoreApp,Version=v6.0" framework. Add a reference to ".NETCoreApp,Version=v6.0" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.
Attempting the other workaround msbuild /t:restore project.vcxproj appears to only restore pure csharp projects referenced by my C++ dll, and does not generate an assets file for the C++ project.
Facing the same issue Build pipelines are failing error NETSDK1004: Assets file 'C:\Projects\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
For C++/CLR with .Net core 7.0
msbuild /t:restore project.vcxproj will only restore the .Net project referenced by CLR
But building the project in visual studio restores both CLR and .Net project
@gureedo @walterlv @GitDaBytes @bharath-brat thanks for reporting the issue!
FYI in Visual Studio 2022 17.7 Preview 2 (released today) there are fixes for CLR .NET projects (aka C++/CLI projects), in particular the projects participating in NuGet's PackageReference
(that is <EnableManagedPackageReferenceSupport>true</>
), are now nuget-restored correctly (not skipped anymore), and also they follow correctly the compatibility rules for the TargetPlatformMoniker (identifier and version).
Let us know if you can try it out and report any feedback, thank you.
@lukka Installed Visual Studio 2022 17.7 Preview 4. I still see there is a dependency with the json file even though this (EnableManagedPackageReferenceSupport - true) available in vcxproj. So the issue doesn't seem to be resolved. Or am I missing something? Can you please let me know.
@Sai-gitacc thank you for reaching out! Could you please create and provide a minimal repro of the problem, with a description of what problem are you hitting? Usually the easier way for doing it is to attach your repro project to a new ticket you can create on Visual Studio's Developer Community. Usually we need to see what is your expectation, what is the actual behavior which differs from the expectation, and the steps to follow to reproduce the issue. Let me know, thank you.
I've performed tests on this repository with the 17.7.0 Preview 4.0 version and I am pleased to report that the issue has been addressed successfully. Thank you for your diligent efforts in resolving this.
Not exactly the same, but related. If you set EnableManagedPackageReferenceSupport
in an older project targeting .NET Framework (ours was targeting v4.7.2), you get a very cryptic error message:
NU1201: Project Imaging is not compatible with net472 (.NETFramework,Version=v4.7.2). Project Imaging supports: native (native,Version=v0.0)
Removing this setting also fixed that. It's not supported on projects targeting .NET Framework, but is enabled by default by VS. Previous versions of VS ignored this setting, but v17.7.0 raises an error.
@ryanbinnsrv thank you for the heads up! Would you be able to provide a sample project which reproduces the problem? I see that the <EnableManagedPackageReferenceSupport>
property is inappropriately set to true
for .NET Framework CLR
projects, but that should not trigger a build failure.
@lukka Attached is a minimal set of two projects that reproduces the issue. Both projects target .NET Framework 4.7.2, but the .vcxproj has the <EnableManagedPackageReferenceSupport>
property set to true
. If you run nuget restore Solution.sln
from the command line, you'll see the error. Note that the projects won't actually build because they have no files in them, but they should get past the nuget restore
stage.
If I remove the <EnableManagedPackageReferenceSupport>
property, the nuget restore
succeeds.
Test.zip
@ryanbinnsrv thank you, the problem will be fixed in VS 17.8. In order to allow the community to raise the importance of this issue, I created a Feedback Ticket at https://developercommunity.visualstudio.com/t/VS-attempts-to-nuget-restore-a-newly-c/10444084 which is used to ponder whether backport to VS 17.7.
@ryanbinnsrv @walterlv and all: let me know if you are experiencing any problem with CLR .NET projects that leverage NuGet's <PackageReference>
. The problems reported in this issue should all be solved in upcoming VS 17.8 (not GA yet as of today). You may try and verify on VS 17.8 Preview.
@marcpopMSFT this issue may be closed if we have positive reaction to this message.
@ryanbinnsrv @walterlv and all: let me know if you are experiencing any problem with CLR .NET projects that leverage NuGet's
<PackageReference>
. The problems reported in this issue should all be solved in upcoming VS 17.8 (not GA yet as of today). You may try and verify on VS 17.8 Preview.@marcpopMSFT this issue may be closed if we have positive reaction to this message.
We fixed this issue by removing the <EnableManagedPackageReferenceSupport>
property from our .vcxproj projects. We have no need for it, so probably won't see any difference. If I get chance, I'll checkout the code revision that had the problem and see if it compiles successfully now.
This problem still happens in Azure Pipelines with a Hosted Agent, using windows-2022 (latest). I am seeing this when the
It seems related to the NuGet pipeline restore... I reported it here https://developercommunity.visualstudio.com/t/NuGet-Command-not-restoring-CCLI-vcx/10734595
Describe the bug
When building any C++ project using the CLR Class Library (.NET) template, the project cannot be successfully built with the MSBuild command line. Instead, it can only be successfully built using Visual Studio 2022. An error, NETSDK1004, occurs when attempting to build the project with MSBuild.
To Reproduce
git clean -xdf
to clean the entire repo, excluding the project filesmsbuild -restore
to build the solutionHere is a repository containing only the newly created project.
Exceptions
Here's the output:
If you want more detail output, I'll post it here.
Known Workarounds
By referring to the official documentation, we can find a workaround by using this command line: devenv SolutionName.sln /Build.
Further technical details
I've tested this issue in two Windows machines and both failed:
Here is an info of the 7.0.202 one: