How to configure output target path for a given resource file in Visual Studio

In the main project of my VS solution, I have a Resources folder with some necessary external tools. When I create and publish a solution, I get it. \ Resources * with all necessary files. So far so good.

However, I need to move some files to the parent directory. My first attempt was to do this using Post Build events. It works and moves them to the correct folder. However, in the published release, they still appear in the Resources folder, and I need them in the parent: /

Is there a way to configure the target output path of resources in Visual Studio?

+6
source share
3 answers

After some research and experimental research, I solved my problem. However, here is what I learned in this process.

The first attempt is to add the file to the root directory of the project and mark it as a resource. After the publication, it worked. But the presence of these files in the project is its root lame.

Since I need some * .exe files compiled in another VS solution, they were added as a reference to the project. I tried it and it passed the Publish test. But still ... not the best way to do this.

After that, with some scenarios and an event after the build, I copied the necessary files to the right folder. It works .. but after publication they do not appear in the package.

However, with the tool of the Magician, there is still the possibility:

http://msdn.microsoft.com/en-us/library/acz3y3te.aspx

This led to some promising experiments, but they helped me understand how limited MS ClickOnce is, so I decided to try other tools.

Here's a good start: What alternatives are available for ClickOnce?

+1
source

I had a similar situation. I found that this became more of a nuisance than it cost to configure output paths, etc. In Visual Studio as much as I wanted.

I ended up having Visual Studio do its thing regarding the file / project structure and write a post-build script to copy everything that was needed into the final, "ready to publish" directory.

Then I set the execution target in Visual Studio to a new location, so I could run / debug as usual, but with a new folder that was organized as I needed it. Caution, I think this is a custom project setup; therefore, other developers will need to do this on their machines, if they so wish.

I really remember changing some output paths, etc., to make post-build scripts easier. But changing such things can lead to annoyance when adding new projects to the solution; You may need to tweak them to match. All this is a compromise :)

0
source

Two ideas:

  • Perhaps you could move your resources to another project - a resource-only project - and then set their Build Action to Content and Copy To Output to true . Then refer to this new project and build a solution. (This may not work the way you want, just an idea).
  • Why not make your resources embedded resources. Store them in the Resources\ directory and access them programmatically?
0
source

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


All Articles