配置MSBuild输出路径 [英] Configure MSBuild output path

查看:95
本文介绍了配置MSBuild输出路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个Windows Forms(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=..\deploy\foo" Targets="Build" />

它将foo.exe和所有本地化的DLL文件复制到deploy\foo文件夹,但是我需要将本地化的DLL文件复制到单独的文件夹中.应该是:

It copies foo.exe and all localized DLL files to the deploy\foo folder, but I need localized DLL files to be copied into a separate folder. It should be:

  • deploy \ foo \ foo.exe
  • deploy \ locales \ ru-RU \ foo.resources.dll
  • deploy \ locales \ pt-BR \ foo.resources.dll

是否可以将MSBuild配置为将EXE和DLL文件复制到其他文件夹?

Is there a way to configure MSBuild to copy EXE and DLL files to different folders?

推荐答案

资源文件的生成和复制是在内部MSBuild过程中进行的:GenerateSatelliteAssembliesCopyFilesToOutputDirectory.它们被复制到输出目录中.

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=..\deploy\foo" Targets="Build" />

<CreateItem Include="..\deploy\foo\**\*.resources.dll">
    <Output TaskParameter="Include" ItemName="ResourcesToMove" />
</CreateItem>

<Move SourceFiles="@(ResourcesToMove)" DestinationFiles="@(ResourcesToMove->'..\deploy\locales\%(RecursiveDir)\%(Filename)%(Extension)')"/>

这篇关于配置MSBuild输出路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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