0

我试图在我的 MSBuild 脚本中使用 AL 任务,每次运行它都会得到不同的结果。

<Target Name="Build"> 
    <PropertyGroup>
        <RootFolder>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</RootFolder>
        <TempDirectory>$(MSBuildProjectDirectory)\temp</TempDirectory>
        <WebsiteDirectory>$(RootFolder)\httpdocs\bin</WebsiteDirectory>
    </PropertyGroup> 

    <ItemGroup>
        <ResourceFilesToDelete Include="$(TempDirectory)\**\*.resources"/>
        <LibraryFilesToCopy Include="$(TempDirectory)\**\*.dll"/>
    </ItemGroup>

    <!-- English translations -->
    <MakeDir Directories="$(TempDirectory)" Condition="!Exists('$(TempDirectory)')"/>
    <GenerateResource Sources="$(MSBuildProjectDirectory)\sitetext.txt" OutputResources="$(TempDirectory)\sitetext.resources"/>
    <AL EmbedResources="$(TempDirectory)\sitetext.resources" OutputAssembly="$(TempDirectory)\sitetext.dll"/>

    <Copy SourceFiles="@(LibraryFilesToCopy)" DestinationFolder="$(WebsiteDirectory)\%(RecursiveDir)"/>
    <Delete Files="@(ResourceFilesToDelete)"/>
</Target>

我基本上有一个文本文件,我想将它转换为资源(作品),然后从中创建一个 dll(作品),但它始终是非常随机的最终复制和删除任务。AL 任务是否存在时间问题?反正有没有暂停,直到他们完成?

4

1 回答 1

1

根本原因是在生成 $(TempDirectory)\sitetext.dll 程序集之前填充了 LibraryFilesToCopy 项目集合。修复很简单:

<!-- English translations -->
<MakeDir Directories="$(TempDirectory)" Condition="!Exists('$(TempDirectory)')"/>
<GenerateResource Sources="$(MSBuildProjectDirectory)\sitetext.txt" OutputResources="$(TempDirectory)\sitetext.resources"/>
<AL EmbedResources="$(TempDirectory)\sitetext.resources" OutputAssembly="$(TempDirectory)\sitetext.dll"/>

<ItemGroup>
    <ResourceFilesToDelete Include="$(TempDirectory)\**\*.resources"/>
    <LibraryFilesToCopy Include="$(TempDirectory)\**\*.dll"/>
</ItemGroup>

<Copy SourceFiles="@(LibraryFilesToCopy)" DestinationFolder="$(WebsiteDirectory)\%(RecursiveDir)"/>
<Delete Files="@(ResourceFilesToDelete)"/>
于 2012-01-06T20:16:04.800 回答