How to enable uncompiled content with a C # program published through Visual Studio

I am trying to publish an XNA game through the Visual Studio Publishing Tool. The game uses compiled and non-fed content. Basically, I have a layer loaded through XML serialization and a short video. These two files are essentially streams, so they do not compile. The publishing tool contains compiled content, but any links to relative paths are broken because CurrentDirectory for installed programs is installed in the AppData folder.

I know that XNA can now compile XML without having to write its own content processors, but I really don't want to go back to rewrite this. I suppose I can, if there is no other option, but this still does not fix the problem with the video.

Is there a way to set up a publishing tool so that I can do what I need to do? Customization or something else? Or do I need to use a more fully functional tool like NSIS?

+4
source share
1 answer

Right-click the project, add an existing resource, browse and select the file you want to add. Then right-click the file and select properties and change “Build Action” to the content and “Copy to Output Directory” to copy if it is newer (or copy if necessary). Then you can access it 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 the "Resoruces" directory that I created in Visual Studio (this is optional, but it helps me keep my project neat)

+7
source

Source: https://habr.com/ru/post/1302103/


All Articles