简体   繁体   中英

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

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" />

Source: https://github.com/NuGet/NuGet.Client/blob/537630019c99fdc7bed1b3dfdade72fc3e31692f/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L1286-L1298


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.

  1. The warning is generated by the WarnForInvalidProjectTask : 在此处输入图像描述

  2. ... which are generated by the _FilterRestoreGraphProjectInputItems target ...

  3. ... which calls a _IsProjectRestoreSupported target , if there is one. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM