Visual Studio/msbuild:设置“内容"输出目录 [英] Visual Studio/msbuild: set "Content" output directory

查看:50
本文介绍了Visual Studio/msbuild:设置“内容"输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实现markerikson在这里的目标:Visual Studio - 发送内容"文件到输出目录而不是子目录?

I'm trying to achieve what markerikson was here: Visual Studio - sending "content" files to the output directory instead of a subdirectory?

问题是,那里的答案(使用 xcopy)是一个黑客.如果我使用内容(在我的例子中是 .dll 和其他数据)添加对项目的引用,那么该内容仍会出现在子文件夹下.

The problem is, the answers there (using xcopy) is a hack. If I add a reference to the project with the content (in my case, .dlls and other data), then the content still appears under a subfolder.

如何设置构建操作 -> 内容并为其中包含的文件设置路径?这种传播方式是,如果我添加对包含项目的引用,文件是否位于引用项目输出中的正确"子文件夹中?内容包括必须在搜索路径中的非托管代码,即在 bin 文件夹中,子文件夹将不起作用.

How can I set Build Action -> Content and set a path for the files contained within? That propagates in such a way that if I add a reference to the containing project, the files are in the 'correct' subfolder in the referencing project's output? The content includes unmanaged code which must in the search path, i.e. in the bin folder, a subfolder will not work.

有很多内容文件,将它们与我的代码放在一起似乎很糟糕.我现在将代码放在子文件夹中,但不正确..

There are many content files and putting them level with my code seems crap. I have my code in a subfolder for now but it's not right..

推荐答案

编辑 .csproj(编辑项目文件,如果您有 生产力电动工具安装)并将文件构建操作更改为 ReferenceComWrappersToCopyLocal.重建.

Edit the .csproj (Edit Project File if you have the Productivity Power Tools installed) and change the file build action to ReferenceComWrappersToCopyLocal. Rebuild.

最终所有 IO 操作都归结为 %FrameworkDir%\v4.0.30319\Microsoft.Common.targets

Ultimately all IO operations boils down to the targets defined in %FrameworkDir%\v4.0.30319\Microsoft.Common.targets

一些复制目标定义DestinationFolder="$(OutDir)"(复制到没有文件夹的输出)和一些定义 DestinationFiles="@(n->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"(保持文件夹结构).

Some copy targets define DestinationFolder="$(OutDir)" (copies to output without folders) and some define DestinationFiles="@(n->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" (keeping folder structure).

您可以看到 CopyLocal=true 的项目被复制到 _CopyOutOfDateSourceItemsToOutputDirectoryAlwaysDestinationFiles,同时保留文件夹结构.

You can see that items with CopyLocal=true gets copied in _CopyOutOfDateSourceItemsToOutputDirectoryAlways with DestinationFiles, while preserving the folder structure.

这篇关于Visual Studio/msbuild:设置“内容"输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆