使用project.json将内容文件包含在nuget包中 [英] Include content files in nuget package using project.json
问题描述
我正在使用此.nuspec文件生成nuget程序包.
I'm using this .nuspec file to generate a nuget package.
<?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
Using this configuration when building a project that references this nuget package the content files will be copied to the output folder. Now I'm converting my project into .Net core project and i want to use the project.json to generate the nuget package and get rid of the .nuspec file. This is my 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?
Now the problem is that when building a project that references this nuget package it will try to compile the content file too. And the build fails. How can I exclude the contentFile from compilation?
推荐答案
您不能在ASP.NET核心包中添加内容.您可以使用bower/npm软件包代替使用内容.
You cannot add contents in ASP.NET core packages. You can go for bower/npm packages instead to use contents.
这篇关于使用project.json将内容文件包含在nuget包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!