我正在使用此.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?
最佳答案
Support for content is currently disabled for similar reasons for scripts and transforms, but we are in the process of designing support for content.
这来自官方的nuget文档页面.你可以找到的信息here.