NuGet - NU5131:未打包在 nuspec 文件中声明的引用
NuGet - NU5131: References declared in the nuspec file are not being packaged
我正在尝试在 nupkg 中引用两个 .dll 文件。我在 nuspec 文件中添加了这些文件作为参考:
<references>
<reference file="Project.Modules.ModuleA.dll" />
<reference file="Project.Modules.ModuleB.dll" />
</references>
当我尝试打包时,收到以下警告并且打包不包含引用的文件。
WARNING: NU5131: References were found in the nuspec, but some
reference assemblies were not found in both the nuspec and ref folder.
Add the following reference assemblies:
- Add Project.Modules.ModuleA.dll to the ref/any/ directory
- Add Project.Modules.ModuleB.dll to the ref/any/ directory
我应该把文件放在哪里才能让包中包含所需的文件?
因为我使用的是 .net core 3.1,结果我所要做的就是在 nupkg 的 project.csproj 文件中做一些调整。这是我所做的:
添加项目组:
<ItemGroup>
<ProjectReference Include="..\..\Project.Modules.ModuleA.csproj" >
<PrivateAssets>all</PrivateAssets>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>Project.Modules.ModuleA.dll</IncludeAssets>
</ProjectReference>
<ProjectReference Include="..\Project.Modules.ModuleB.csproj" >
<PrivateAssets>all</PrivateAssets>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>Project.Modules.ModuleB.dll</IncludeAssets>
</ProjectReference>
</ItemGroup>
然后添加目标:
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
最后在 PropertyGroup 元素中添加:
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
对我来说很有魅力
我正在尝试在 nupkg 中引用两个 .dll 文件。我在 nuspec 文件中添加了这些文件作为参考:
<references>
<reference file="Project.Modules.ModuleA.dll" />
<reference file="Project.Modules.ModuleB.dll" />
</references>
当我尝试打包时,收到以下警告并且打包不包含引用的文件。
WARNING: NU5131: References were found in the nuspec, but some reference assemblies were not found in both the nuspec and ref folder. Add the following reference assemblies: - Add Project.Modules.ModuleA.dll to the ref/any/ directory - Add Project.Modules.ModuleB.dll to the ref/any/ directory
我应该把文件放在哪里才能让包中包含所需的文件?
因为我使用的是 .net core 3.1,结果我所要做的就是在 nupkg 的 project.csproj 文件中做一些调整。这是我所做的:
添加项目组:
<ItemGroup>
<ProjectReference Include="..\..\Project.Modules.ModuleA.csproj" >
<PrivateAssets>all</PrivateAssets>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>Project.Modules.ModuleA.dll</IncludeAssets>
</ProjectReference>
<ProjectReference Include="..\Project.Modules.ModuleB.csproj" >
<PrivateAssets>all</PrivateAssets>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<IncludeAssets>Project.Modules.ModuleB.dll</IncludeAssets>
</ProjectReference>
</ItemGroup>
然后添加目标:
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
最后在 PropertyGroup 元素中添加:
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
对我来说很有魅力