2

我正在编写自定义 MSBuild 目标,它在特定条件下替换了一些<PackageReference>for 。<ProjectReference>

我有以下 msbuild 目标:

<Target Name="ApplyProjectRedirects"
      BeforeTargets="_GenerateDotnetCliToolReferenceSpecs;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences;BeforeResolveReferences;ResolveAssemblyReferences"
      AfterTargets="PaketRestore">

    <ItemGroup>
      <!-- remove packages we are redirecting to projects, and include the projects -->
      <PackageReference Remove="@(ExcludePackageReferences)" />
      <ProjectReference Include="@(IncludeProjectPaths)" />
    </ItemGroup>

    <ItemGroup>
      <!-- include the packages in visual studio 'nuget' display, so we know what we redirected -->
      <PackageReference Include="@(ExcludePackageReferences)">
        <ExcludeAssets>all</ExcludeAssets>
      </PackageReference>
    </ItemGroup>

</Target>

而且我的项目引用在 Visual Studio 依赖项中是不可见的。但是,项目按预期编译。

我发现当目标在之前运行时<ItemGroup><PackageReference>内部目标受到尊重CollectPackageReferences。但是,我无法填写<ProjectReference>任何目标,即使是第一个目标。

Visual Studio 如何使用解决方案项目填充依赖项?

4

0 回答 0