c#-Visual Studio在NuGet包中错误地包装了wwwroot
作者:互联网
我目前正在利用新的Visual Studio 2017工具从具有project.json格式的* .xproj升级到* .csproj文件格式.以下是我同时用于IDE和SDK / .NET Core CLI的版本:
Visual Studio版本
Microsoft Visual Studio Community 2017
Version 15.4.3
VisualStudio.15.Release/15.4.3+27004.2008
Microsoft .NET Framework
Version 4.7.02558
SDK / .NET Core CLI
.NET Command Line Tools (2.0.2)
Product Information:
Version: 2.0.2
Commit SHA-1 hash: a04b4bf512
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.2\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
话虽如此,我很好奇如何在不依赖.nuspec的情况下将wwwroot从我的NuGet包中排除.这可能吗?
.csproj
这是我的.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<!-- omitted for brevity -->
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\**\*;node_modules" />
<EmbeddedResource Include="Views\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>lib/net461/</PackagePath>
<Pack>true</Pack>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<!-- package references, omitted for brevity -->
</ItemGroup>
</Project>
包装内容
这是包装内容的图像:
理想情况下,我想让内容类似于排除content和contentFiles位,而只是具有.exe的lib.
解决方法:
您可以修改项目文件中的内容项,以将wwwroot文件夹或所有内容项的Pack元数据设置为false:
<ItemGroup>
<!-- only exclude wwwroot items from package -->
<Content Update="wwwroot/**" Pack="false" />
<!-- Exclude all content from package (e.g. appsettings.json) -->
<Content Update="@(Content)" Pack="false" />
</ItemGroup>
标签:net-core,nuget,visual-studio-2017,c 来源: https://codeday.me/bug/20191110/2014662.html