配置 MSBuild 输出路径 [英] Configure MSBuild output path
问题描述
有一个带有本地化资源文件的 Windows 窗体 (NET 3.5) 项目 foo.csproj.我使用 MSBuild 构建项目并创建部署结构:
There is a Windows Forms (NET 3.5) project, foo.csproj, with localized resources files. I use MSBuild to build the project and create a deployment structure:
<MSBuild Projects="foo.csproj" Properties="Configuration=Release;OutputPath=..deployfoo" Targets="Build" />
它将 foo.exe 和所有本地化的 DLL 文件复制到 deployfoo
文件夹,但我需要将本地化的 DLL 文件复制到单独的文件夹中.应该是:
It copies foo.exe and all localized DLL files to the deployfoo
folder, but I need localized DLL files to be copied into a separate folder. It should be:
- 部署foofoo.exe
- 部署locales u-RUfoo.resources.dll
- 部署localespt-BRfoo.resources.dll
有没有办法配置 MSBuild 将 EXE 和 DLL 文件复制到不同的文件夹?
Is there a way to configure MSBuild to copy EXE and DLL files to different folders?
推荐答案
资源文件的生成和复制在构建期间在内部 MSBuild 过程中完成:GenerateSatelliteAssemblies
和 CopyFilesToOutputDirectory
.它们被复制到输出目录中.
Resource files generation and copy is done in an internal MSBuild process during the build: GenerateSatelliteAssemblies
and CopyFilesToOutputDirectory
. They are copied in the output directory.
据我所知,您无法修改此行为.
As far as I know, you can't modify this behavior.
您必须在构建步骤之后移动资源文件.我建议使用 MSBuild 社区任务中的 Move
任务.
You have to move your resources files after the build step. I would advise to use the Move
task from MSBuild community tasks.
<MSBuild Projects="foo.csproj" Properties="Configuration=Release;OutputPath=..deployfoo" Targets="Build" />
<CreateItem Include="..deployfoo***.resources.dll">
<Output TaskParameter="Include" ItemName="ResourcesToMove" />
</CreateItem>
<Move SourceFiles="@(ResourcesToMove)" DestinationFiles="@(ResourcesToMove->'..deploylocales\%(RecursiveDir)\%(Filename)%(Extension)')"/>
这篇关于配置 MSBuild 输出路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!