[英]How to include non-compiled content alongside a C# program published via Visual Studio
I'm trying to publish an XNA game through the Visual Studio Publish tool. 我正在尝试通过Visual Studio发布工具发布XNA游戏。 The game uses some compiled and some non-compiled content.
游戏使用一些编译和一些非编译的内容。 Basically, I have a level loaded in via XML serialization and a short video.
基本上,我通过XML序列化和短视频加载了一个级别。 These two files are essentially streamed in, so they aren't compiled.
这两个文件基本上是流式传输的,因此它们不会被编译。 The publish tool includes the compiled content fine, but any references to relative paths are broken because the CurrentDirectory for installed programs are set in the AppData folder.
发布工具包含已编译的内容,但是对相对路径的任何引用都会被破坏,因为已安装程序的CurrentDirectory是在AppData文件夹中设置的。
I know that XNA can now compile XML without having to write custom content processors, but I don't particularly want to go back to rewrite that. 我知道XNA现在可以编译XML而无需编写自定义内容处理器,但我不想特别想重新编写它。 I suppose I can if there's no other option, but that still doesn't remedy the video problem.
我想我可以,如果没有其他选择,但仍然无法解决视频问题。
Is there any way to set up the publish tool so that I can do what I need to do? 有没有办法设置发布工具,以便我可以做我需要做的事情? A setting or something?
设置还是什么? Or will I need to use a more fully-featured tool like NSIS?
或者我需要使用像NSIS这样功能更全面的工具吗?
Right click project, Add Existing Resource, browse and select the file you want to add. 右键单击项目,添加现有资源,浏览并选择要添加的文件。 Then right click the file and click properties and change "Build Action" to content, and "Copy To Output Directory" to Copy if newer (or copy always if the need be).
然后右键单击该文件并单击属性并将“构建操作”更改为内容,将“复制到输出目录”更改为“如果更新则复制”(或者如果需要则始终复制)。 Then you can access it by using the relative path.
然后,您可以使用相对路径访问它。
I use this for my XML and I can access my content using the following code: 我将它用于我的XML,我可以使用以下代码访问我的内容:
XmlDocument document = new XmlDocument();
document.Load("Resources/DefaultConfig.xml");
Please note that my DefaultConfig.xml file is inside a "Resoruces" Directory which I created in Visual Studio(this is optional, but it helps me keep my project neat) 请注意我的DefaultConfig.xml文件位于我在Visual Studio中创建的“Resoruces”目录中(这是可选的,但它可以帮助我保持项目整洁)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.