【发布时间】:2017-01-25 18:29:03
【问题描述】:
我正在使用这个 .nuspec 文件来生成一个 nuget 包。
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>ClassLibrary1</id>
<version>1.0.0</version>
<title>Title</title>
<authors>Author</authors>
<owners>Owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright 2017</copyright>
<contentFiles>
<files include="any/any/myfile.xml" buildAction="None" copyToOutput="true" flatten="true" />
</contentFiles>
</metadata>
</package>
在构建引用此 nuget 包的项目时使用此配置,内容文件将被复制到输出文件夹。 现在我将我的项目转换为 .Net 核心项目,我想使用 project.json 来生成 nuget 包并摆脱 .nuspec 文件。 这是我的 project.json
{
"version": "1.0.0-*",
"dependencies": { },
"frameworks": {
"net452": {
}
},
"packOptions": {
"files": {
"mappings": {
"contentFiles/any/any/myfile.xml": "Configuration/myfile.xml"
}
}
},
"scripts": {
"postcompile": [
"dotnet pack --no-build --configuration %compile:Configuration%"
]
}
}
现在的问题是,在构建引用此 nuget 包的项目时,它也会尝试编译内容文件。并且构建失败。 如何从编译中排除 contentFile?
【问题讨论】:
标签: c# asp.net-core nuget