NetCore 项目直接在项目根级别下显示来自 nuget 包的托管 dll
NetCore project shows managed dlls from nuget package directly under project root level
我创建了包含第三方 dll 的 Nuget 包。
(它针对netstandard2.0和net462)
dll 与 "MyLib.targets" 文件一起在 nuget 包中的 "build" 级别下。
"lib" 级别为 MyLib.dll。
如果我将 nuget 包与 net462 项目一起使用,一切看起来都很好。
该 dll 在项目中不可见,将被复制到输出目录(感谢 .targets 文件)。
如果我创建 NetCore2.0 项目并使用我的包,它工作正常并且 dll 被复制到输出目录,但是
所有 dll(其中 12 个)都将在项目根目录下的 VS 中可见。
所以我的 Program.cs 文件在 dll 地狱中结束了。
如果我尝试删除它们,我会收到消息:
无法修改源自导入文件的评估对象.....targets.
有没有办法从 Visual Studio 项目中隐藏我的 Nuget 包附带的第三方 dll?
.targets 文件是堆栈溢出的片段:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.*" Exclude="$(MSBuildThisFileDirectory)**\*.targets" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
您可以将 Visible
元数据设置为 false
以告诉 VS 不在解决方案资源管理器中显示项目:
<None Include="…">
…
<Visible>false</Visible>
</None>
有关元数据属性的文档,请参阅 Common MSBuild Project Items。
我创建了包含第三方 dll 的 Nuget 包。 (它针对netstandard2.0和net462)
dll 与 "MyLib.targets" 文件一起在 nuget 包中的 "build" 级别下。
"lib" 级别为 MyLib.dll。
如果我将 nuget 包与 net462 项目一起使用,一切看起来都很好。 该 dll 在项目中不可见,将被复制到输出目录(感谢 .targets 文件)。
如果我创建 NetCore2.0 项目并使用我的包,它工作正常并且 dll 被复制到输出目录,但是 所有 dll(其中 12 个)都将在项目根目录下的 VS 中可见。 所以我的 Program.cs 文件在 dll 地狱中结束了。
如果我尝试删除它们,我会收到消息: 无法修改源自导入文件的评估对象.....targets.
有没有办法从 Visual Studio 项目中隐藏我的 Nuget 包附带的第三方 dll?
.targets 文件是堆栈溢出的片段:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.*" Exclude="$(MSBuildThisFileDirectory)**\*.targets" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
您可以将 Visible
元数据设置为 false
以告诉 VS 不在解决方案资源管理器中显示项目:
<None Include="…">
…
<Visible>false</Visible>
</None>
有关元数据属性的文档,请参阅 Common MSBuild Project Items。