如何将未编译的内容与通过 Visual Studio 发布的 C# 程序一起包含

发布于 2024-08-22 04:34:46 字数 350 浏览 4 评论 0原文

我正在尝试通过 Visual Studio 发布工具发布 XNA 游戏。游戏使用了一些编译内容和一些非编译内容。基本上,我通过 XML 序列化和一个短视频加载了一个关卡。这两个文件本质上是流式传输的,因此它们不会被编译。发布工具可以很好地包含已编译的内容,但对相对路径的任何引用都会被破坏,因为已安装程序的 CurrentDirectory 是在 AppData 文件夹中设置的。

我知道 XNA 现在可以编译 XML,而无需编写自定义内容处理器,但我并不特别想回去重写它。我想如果没有其他选择的话我可以,但这仍然不能解决视频问题。

有什么方法可以设置发布工具,以便我可以做我需要做的事情?设定什么的?或者我需要使用像 NSIS 这样功能更齐全的工具吗?

I'm trying to publish an XNA game through the Visual Studio Publish tool. The game uses some compiled and some non-compiled content. Basically, I have a level loaded in via XML serialization and a short video. 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.

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. 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归途 2024-08-29 04:34:46

右键单击项目,添加现有资源,浏览并选择要添加的文件。然后右键单击该文件,然后单击属性,然后将“构建操作”更改为内容,将“复制到输出目录”更改为如果更新则复制(或者如果需要则始终复制)。然后就可以使用相对路径来访问了。

我将其用于我的 XML,并且可以使用以下代码访问我的内容:

XmlDocument document = new XmlDocument();
document.Load("Resources/DefaultConfig.xml");

请注意,我的 DefaultConfig.xml 文件位于我在 Visual Studio 中创建的“Resoruces”目录内(这是可选的,但它可以帮助我保留我的项目)整洁的)

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:

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文