开发者

How to setup the target output path of a given resource file in Visual Studio

In the main project of my VS Solution I have a Resources folder with some required external tools. When building and publishing the solution, I get a .\Resources* with all required files there. So far so good.

However I have to move some files to开发者_如何学C the parent directory. My first attempt was do so with the Post Build Events. It works and does move them the correct folder. Nevertheless in the publish output they still appear in the Resources folder and I need them in the parent one :/

Is there any way to setup the target output path for resources in Visual Studio?


After some research and experimental, I solved my problem. Still, here's what I learned in the process.

The first attempt was adding the file to the project root and mark it as a resource. After publishing it worked. But having those files in the project root its lame.

Since I needed some *.exe files compiled in another VS solution, added them as a project reference. Gave it a try and it passed the "Publish" test. But still.. not the best way to do it.

After that, with some scripting and a post-build event, I copied the required files to the correct folder. Works.. but after publishing, they don't appear in the package.

However, there is still a possibility with the Mage tool:

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

This lead to some promissing experiments, however they ended up helping me realize how limited the MS ClickOnce is, so I decided to try other tools.

Here's a good start to follow: What alternatives are there to ClickOnce?


I had a similar situation once. I found it became more trouble than it was worth to customize output paths and such in Visual Studio, to the extent that I wanted.

I ended up letting Visual Studio do its own thing with regards to file/project structure, and wrote a post-build script to copy everything that was needed into a final, 'publish-ready' directory.

I then set the execution target in Visual Studio to the new location, so I could run/debug as normal, but with the new folder that was organized how I needed it. Careful, I think this is a user project setting; so other developers will need to do this on their machines too, if they so desire.

I do recall changing some output paths and such to make the post-build script more simple. But changing things like that can lead to annoyances when you add new projects to the solution; you might need to configure them to match. It's all a trade-off :)


Two ideas:

  • Maybe you could move your resources into another project - a project just for resources - and then set their Build Action to Content and Copy To Output to true. Then reference this new project and build the solution. (This may not work as you want, just an idea).
  • Why not make your resources embedded resources instead. Keep them all within the Resources\ directory and access them programatically?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜