如何在 Visual Studio 2008 中使智能感知与 NANT 文件一起使用?
我从一个空项目开始,并尝试使用
以下命令来设置我的构建文件:
- 通过使用 -help 选项运行 NAnt,找出我正在使用的 NAnt 版本。
- 在以下字符串中替换了我在以下 URL 中使用的 NAnt 版本:
- http://nant.sourceforge.net/release/<我的 NAnt 版本>/nant.xsd
- 在此示例中,假设该值为 0.90。
- 下载文件:从上面的 URL 到 %VS_HOME%\Common7\Packages\schemas\xml
- http://nant.sourceforge.net/release/0.90/nant.xsd
- 在 VS 中打开我的构建文件(来自我的解决方案和项目)
- 从菜单中单击 XML- >Schemas... 添加我之前下载的 nant.xsd 到 IDE。
- 添加架构后,请确保在 XML Schemas 窗口的 Use 列中,它旁边有一个绿色复选标记。
- 在
中添加了以下属性:我的构建文件的元素: - <项目... xmlns="http://nant.sourceforge.net/release/0.90/nant.xsd">
- 单击确定 XML 架构窗口。
- 最后,我使用打开方式...XML 编辑器重新打开了我的构建文件。
在错误列表中执行上述过程后,我在消息部分中获得了一个列表,但在输入时没有收到任何智能感知建议(除了 XML 的默认值,像 !--, ![CDATA[, 和 ?)
我还需要更改其他内容才能使其在 VS2008 中工作吗?
I started with an Empty Project, and tried to get my build file setup with
Here's what I have tried so far:
- Found out what version of NAnt I'm using by running NAnt with the -help option.
- In the following string replaced the version of NAnt I'm using in the following URL:
- http://nant.sourceforge.net/release/<my NAnt version>/nant.xsd
- In this example, lets say it's 0.90.
- Downloaded the file: from the above URL to %VS_HOME%\Common7\Packages\schemas\xml
- http://nant.sourceforge.net/release/0.90/nant.xsd
- Opened my buildfile in VS (from instide my solution and project)
- From the menu clicked XML->Schemas... to add add the nant.xsd I downloaded earlier to the IDE.
- After adding the schema made sure that it had a green checkmark next to it in the Use column of the XML Schemas window.
- Added the following attribute in the <project> element of my build file:
- <project ... xmlns="http://nant.sourceforge.net/release/0.90/nant.xsd" >
- Clicked OK on XML Schemas window.
- Lastly, I reopened my buildfile with the open with... the XML Editor.
After performing the above procedure in the Error List I get a list in the messages section but I don't get any intellisense suggestions when typing (other than the defaults for XML, like !--, ![CDATA[, and ?)
Is there something else I need to change to make this work in VS2008?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将我拥有的版本 (0.85) 附带的
nant.xsd
文件添加到 VS 中设置的架构中,然后将其添加到我的构建文件中:并且工作正常。您确定为 0.90 版本声明的 XML 命名空间正确吗?也许是sf.net而不是sourceforge.net。
I added the
nant.xsd
file that ships with the version I have (0.85) to the schemas set in VS and then added this to my build file:And it worked fine. Are you sure the XML namespace you're declaring for the 0.90 release is correct? Maybe it's sf.net rather than sourceforge.net.
查看 nantschema 任务。您可以让 nant 吐出自己的 XML 模式,其中包括任何第三方扩展(nantcontrib、自定义任务等)。
我在我的开发机器上设置了一个名为 nant.myprojectname.com 的网站(其中 myprojectname 替换为我想要调用我的项目的任何名称),并且我得到 nant 将架构 xsd 文件复制到那里作为构建过程的一部分。我只是将 nant.myproject.com 放入本地主机文件中,以使其在本地开发计算机上解析 - 我真的不需要其他地方可用的模式。
然后,我将以下内容放入 nant 项目元素中:
schemaLocation 属性告诉 Visual Studio(或其他)查看 http ://nant.myprojectname.com/myprojectnamenant.xsd 用于架构。可能需要在 Intellisense 启动之前重新加载 VS。
Take a look at the nantschema task. You can get nant to puke out its own XML schema which will include any third-party extensions (nantcontrib, custom tasks, etc).
I have setup a website on my dev machine called nant.myprojectname.com (where myprojectname is replaced by whatever I want to call my project) and I get nant to copy the schema xsd file there as part of the build process. I just put nant.myproject.com into the local hosts file to get it to resolve on the local dev machine - I don't really need the schema available elsewhere.
I then put the following into the nant project element :
The schemaLocation attribute tells Visual Studio (or whatever) to look at http://nant.myprojectname.com/myprojectnamenant.xsd for the schema. May need to reload VS before Intellisense kicks in.
我回答这个问题有点晚了,但我正在寻找这个问题的解决方案,同时也希望NAntContrib具有智能感知。为此,请按照以下步骤操作:
第 1 步:您需要为新的
nant.sxd
创建构建脚本,我们将此文件命名为nantxsd.build 包含 NAntContrib 任务:
第 2 步: 然后从命令行构建新的
nant.xsd
文件。如果您已经安装了 NAnt,您应该能够在 nanntxsd.build 脚本所在的目录中打开命令行窗口并运行:步骤 3: 将新的 nant.xsd 复制到 Visual Studio XML\Schemas 文件夹。例如:
I'm a bit late to this question, but I was searching for the solution to this problem with the twist of wanting intellisense for NAntContrib as well. To do this follow these steps:
Step 1: You need to create a build script for the new
nant.sxd
, let's call this filenantxsd.build
that includes the NAntContrib tasks:Step 2: Then build the new
nant.xsd
file from the command line. If you have installed NAnt you should be able to open the command line window in the same directory as thenanntxsd.build
script and run:Step 3: Copy the new nant.xsd to the Visual Studio XML\Schemas folder. For example: