-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Sequence contains no elements" exception during msbuild after restore - .NET 7 #154
Comments
More info:
Whereas |
A project.assets.json is actually the desired result, as there is a global package reference in Directory.Packages.props for an MSBuild plugin that needs to be applied to all projects. |
Verified still present in just-released VS 17.4.3 (MSBuild version 17.4.1+9a89d02ff for .NET Framework) |
For future reference on the NU1503 error under <!-- Must be first import for .vcxproj files. On Windows, $(VCTargetsPath) is needed to bootstrap common and C++
.props and .targets files but it's only set in an MSBuild.exe environment via
MSBuild.exe.config (see https://github.com/dotnet/msbuild/blob/main/src/MSBuild/app.amd64.config#L194 ).
'dotnet restore' does not invoke MSBuild.exe and there is no MSBuild.dll.config with this property,
hence VCTargetsPath is never set, making it impossible to bootstrap C++ imports.
Additionally in dotnet restore $(MSBuildExtensionsPath32) is not the same as for MSBuild.exe.
Set the default value to what MSBuild would have done. -->
<Project>
<PropertyGroup>
<VCTargetsPath Condition=" '$(OS)' == 'Windows_NT' and '$(VCTargetsPath)'=='' ">$(ProgramFiles)\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\</VCTargetsPath>
</PropertyGroup>
</Project> |
I'm hitting this same problem and would love to see this get fixed! |
Found one workaround from https://github.com/japj/CppWithNuGetPackageReference/blob/master/Directory.Build.props that adds a nuget fallback. When I set this in <!-- Enable NuGet TargetMonikers fallback to vcxproj. https://github.com/japj/CppWithNuGetPackageReference/blob/master/Directory.Build.props -->
<PropertyGroup>
<_NuGetTargetFallbackMoniker>$(_NuGetTargetFallbackMoniker);native,Version=v0.0</_NuGetTargetFallbackMoniker>
</PropertyGroup> |
Not sure if this will help anybody until this issue is fixed, but got the same annoying problem on a CMake mixed CXX + C# project. My
Obviously your |
In case it helps someone, I got this error because multiple projects (generated by CMake) were sharing the same 'obj' folder. I could work around it by creating a Directory.Build.props file ensuring the obj-path for each project is unique: <Project>
<PropertyGroup>
<BaseIntermediateOutputPath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
</PropertyGroup>
</Project> |
After converting a fully working .NET 6 repo to .NET 7 and VS 17.4.2, command line builds started failing with exceptions from NuGet.BuildTasks. This occurs on Windows only, and only within .vcxproj projects. The repo uses
Directory.Packages.props
global packages. It does not occur ifdotnet restore
is used (see below), just when restoring withmsbuild /t:Restore
. It usually does not happen in Visual Studio. Our ADO based build pipeline does not repro this, but it usesdotnet restore
.Repro sequence in our repo:
git clean -xfd
at rootmsbuild /t:Restore
(works successfully)msbuild /p:Configuration=Debug
Interestingly, with the same exact machine,
dotnet restore
instead ofmsbuild /t:Restore
does not reproduce the problem.Exact MSBuild version from console output:
The exception stack:
The text was updated successfully, but these errors were encountered: