我有一个需要自动化生成附属程序集的过程的过程。具体来说,这是针对 WPF 和结合 Resx 和 BAML 资源的。
我有一个可以工作的构建脚本,但它需要手动添加我想与 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.
我已经尝试了很多东西。使用构建过程显然在错误的时间触发,最终无法找到文件。