如何在 NuGet 包中包含配置部分的 XSD 文件? [英] How do I include an XSD file for a configuration section with a NuGet package?

查看:81
本文介绍了如何在 NuGet 包中包含配置部分的 XSD 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有非常详细的配置部分的库.我已经创建了一个 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 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆