我有一个需要自动生成附属程序集的过程。具体来说,这是为WPF和Resx和BAML资源的结合。使用MsBuild生成和编译.resources文件
我有一个可以工作的构建脚本,但它需要手动添加我想与BAML资源结合使用的.resources文件。 IOW,每次添加.Resx资源时,我都必须添加到构建脚本中。不爽!
目前我正在手动运行集链接和脚本如下所示:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Adds the build action 'LocBamlCsv' -->
<ItemGroup>
<AvailableItemName Include="LocBamlCsv" />
</ItemGroup>
<Target Name="CreateSatelliteAssemblies"
DependsOnTargets="$(CreateSatelliteAssembliesDependsOn)">
<!-- Locbaml needs the runtime assemblies in the intermediate dir -->
<Copy SourceFiles="$(ProjectDir)..\Tools\LocBaml.exe"
DestinationFolder="$(OutputPath)" />
<!-- generate a .resources file for .csv merged output -->
<Exec Command="LocBaml /generate ..\..\$(IntermediateOutputPath)$(TargetName).g.$(UICulture).resources /trans:%(LocBamlCsv.FullPath) /out:../../$(IntermediateOutputPath) /cul:%(LocBamlCsv.Culture)"
WorkingDirectory="$(OutputPath)"
Outputs="$(OutputPath)%(LocBamlCsv.Culture)\$(TargetName).$(UICulture).dll" />
<!-- Generate the resource assembly by merging all .resources files -->
<!-- NOTE: Explicitly add any resource files here -->
<Exec Command="al /template:$(TargetName).exe /culture:%(LocBamlCsv.Culture) /out:%(LocBamlCsv.Culture)\$(TargetName).resources.dll /embed:$(TargetName).g.%(LocBamlCsv.Culture).resources /embed:$(TargetName).Properties.Resources.%(LocBamlCsv.Culture).resources"
WorkingDirectory="$(InterMediateOutputPath)"
/>
</Target>
</Project>
如前所述它的工作原理。但如果有一些使用通配符的方法(即$(TargetName).s。%(LocBamlCsv.Culture).resources),那么调用al的最后一个命令将更容易处理。
我已经尝试了很多东西,使用构建过程显然在错误的时间点燃,最终无法找到文件。
你总是可以写扫描目录* .RES或什么,并生成构建脚本的脚本。 – 2009-06-14 03:08:14
杰夫如何做到这一点的任何链接?我不熟悉msbuild,我不知道如何获取文件并将它们传递到链接器路径。另一个问题是部分不起作用(即使使用硬编码的文件名 - 大概是因为构建过程中这些文件可用的时间是错误的)显式命令的作用。 –
2009-06-14 03:15:43