'Skipping restore for project 'SetupWix.wixproj'. The project file may be invalid or missing targets required for restore (NU1503)
We are using Wixtoolset V3.9 to build our setup. We use the following command to start a build:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /restore /t:Rebuild /p:Configuration=Release /p:Platform=x64 MySolution.sln /p:BabelEnabled=true
We need the parameter /restore to restore the nuget-packagages on our build-server. Since we build our Wix-Setup by MSBUILD 16 we get the following warning:
Skipping restore for project 'SetupWix.wixproj'. The project file may be invalid or missing targets required for restore.
The warning belongs to category NU1503 (whatever this means). We cannot find a way to solve or even suppress this warning. We have tried to suppress it by adding the code NU1503 to the Project-Properties:
Whatever the reason, the warning still appears.
Question: How can we solve or suppress this warning?
Solution 1:[1]
TL;DR
You can get rid of NU1503 by including this in your .proj / msbuild file:
<!-- prevents NU1503 -->
<Target Name="_IsProjectRestoreSupported"
Returns="@(_ValidProjectsForRestore)">
<ItemGroup>
<_ValidProjectsForRestore Include="$(MSBuildProjectFullPath)" />
</ItemGroup>
</Target>
<Target Name="Restore" />
Detailed explanation
I figured this out by inspecting the msbuild.binlog file via dotnet restore /bl with the awesome MSBuild Binary Log File Viewer tool.
The warning is generated by the
WarnForInvalidProjectTask:
... which are generated by the
_FilterRestoreGraphProjectInputItemstarget...... which calls a
_IsProjectRestoreSupportedtarget, if there is one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

