我的Nuget包没有合并静态内容

时间:2016-09-26 17:56:41

标签: visual-studio-2015 asp.net-core nuget

我为VS 2015创建了一个Nuget包,.Net Core MVC,框架目标为4.61。

我的nuspec看起来像这样:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>MyThing</id>
    <version>0.9.5</version>
    <authors>Me</authors>
    <owners>Us</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>This should merge in this content, but doesn't</description>
    <releaseNotes></releaseNotes>
    <copyright>Copyright 2016</copyright>
    <tags>Core MVC</tags>
    <dependencies>
      <dependency id="Microsoft.AspNetCore.Diagnostics" version= "1.0.0"/>
      <dependency id="Microsoft.AspNetCore.Mvc" version= "1.0.0"/>
      <dependency id="Microsoft.AspNetCore.Server.IISIntegration" version= "1.0.0"/>
      <dependency id="Microsoft.AspNetCore.Server.Kestrel" version= "1.0.0"/>
      <dependency id="Microsoft.AspNetCore.StaticFiles" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Configuration.EnvironmentVariables" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Configuration.Json" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Logging" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Logging.Console" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Logging.Debug" version= "1.0.0"/>
      <dependency id="Microsoft.Extensions.Options.ConfigurationExtensions" version= "1.0.0"/>
      <dependency id="Microsoft.VisualStudio.Web.BrowserLink.Loader" version= "14.0.0"/>
      <dependency id="xunit" version= "2.1.0"/>
      <dependency id="xunit.runner.console" version= "2.1.0"/>
      <dependency id="xunit.runner.visualstudio" version= "2.1.0"/>
      <!--dependency id="dotnet-test-xunit" version= "1.0.0-rc2-build10025"/-->
    </dependencies>
    <contentFiles>
      <!-- Include Assets as Content -->
      <files include="**/wwwroot/**/*.*" buildAction="EmbeddedResource" />
      <files include="**/Controllers/*.*" copyToOutput="true" />
      <files include="**/Model/*.*" buildAction="None" />
      <files include="**/Views/*.*" buildAction="None" copyToOutput="true" />
      <files include="**/Views/**/*.*" buildAction="EmbeddedResource" copyToOutput="true" />
    </contentFiles>
  </metadata>
</package>

各种包含参数是为了证明它们都不起作用。这些文件不会复制到它们添加到的项目中,但它们存在于nuget包缓存中。

1 个答案:

答案 0 :(得分:0)

当我使用相同的.nuspec文件内容时,我遇到了同样的问题。我通过解压缩nupkg文件检查了包,<contentFiles>标签中列出的所有文件都成功打包到包中。但是这些文件没有安装到安装软件包的项目中。

即使文件未在项目结构中显示,内容文件也会按预期工作。例如,如果您在<contentsFiles>中满足.cs文件,则在安装软件包之后,您可以使用此.cs文件中的类和成员。

请参阅: NuGet 3.3+: contentFiles not added to project