我有一个带有非常详细的配置部分的库.我已经创建了一个 XSD 并希望将它与我的包一起分发,这样当用户安装包时,Visual Studio 知道 XSD,而用户不需要做任何额外的事情.我该怎么做?
I have a library with a pretty verbose configuration section. I've created an XSD and would like to distribute that with my package so that when a user installs the package, Visual Studio knows about the XSD without the user needing to do anything extra. How do I do this?
推荐答案您可以通过将任何文件放在内容目录中来将它们包含在 nuget 包中.安装包后,这些将被安装到目标项目的根目录中.如果您使用 nuspec 文件来构建您的包,您需要在该元素下添加以下元素.
You can include any files you want in a nuget package by placing them in the content directory. These will then be installed into the root of your target project when the package is installed. If you're using a nuspec file to build your package you would add the following element under the element.
<files> <file src="Configuration\MyXsd.xsd" target="content\TargetFolderName" /> </files>这将在目标项目中创建以下文件
This will create the following file in the target project
\TargetFolderName\MyXsd.xsd一旦 xsd 在目标项目中,visual studio 应该自动选取它以验证您的配置部分.
Once the xsd is in the target project visual studio should pick it up automatically for validating your config section.
更多推荐
如何在 NuGet 包中包含配置部分的 XSD 文件?
发布评论