2

这是有问题的,因为传入的任何属性都会丢失。

进一步说明:我将一个属性传递给项目文件。此属性是 .props 文件的路径。它包含 detokenise 类的标记和替换值。该任务显然会重新加载项目并且不维护路径。其他任务似乎并非如此,例如 guid 任务。

在示例中,我使用了一个名为 guids.proj 的示例项目

调用使用:

<MSBuild.ExtensionPack.FileSystem.Detokenise TaskAction="Detokenise" TargetFiles="@(FileCollectionToBeDetokenized )"/>

一些命令行输出如下:

Task "MSBuild.ExtensionPack.FileSystem.Detokenise" (TaskId:11) Detokenise Task Execution Started [13:04:35] (TaskId:11) Loading Project: C:\Users\bstrausser\Desktop\guids.proj (TaskId:11) Detokenising Collection: 1 files (TaskId:11) C:\Users\*****\Desktop\guids.proj(37,9): error : Property not found: Asset Directory

完整的项目文件:

Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(ParentMSBuildProjectDirectory)\Bin\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks" Condition="Exists('$(ParentMSBuildProjectDirectory)\Bin\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks')"/>
<Import Project="C:\Program Files (x86)\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks" Condition="!Exists('$(ParentMSBuildProjectDirectory)\Bin\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks') AND Exists('C:\Program Files (x86)\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks')"/>

<PropertyGroup>
    <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
    <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    <PROPS>$(DACP)</PROPS>
</PropertyGroup>

<Import Project="$(PROPS)" Condition="'$(DACP)' != ''" />

<Target Name="Default">
    <Message text = "$(DACP)" />
    <!-- Create a new Guid and get the formatted and unformatted values -->
    <MSBuild.ExtensionPack.Framework.Guid TaskAction="Create">
        <Output TaskParameter="FormattedGuidString" PropertyName="FormattedGuidString1" />
        <Output TaskParameter="GuidString" PropertyName="GuidStringItem" />
    </MSBuild.ExtensionPack.Framework.Guid>
    <Message Text="GuidStringItem: $(GuidStringItem)"/>
    <Message Text="FormattedGuidString: $(FormattedGuidString1)"/>
    <!-- Create a new cryptographically strong Guid and get the formatted and unformatted values -->
    <MSBuild.ExtensionPack.Framework.Guid TaskAction="CreateCrypto">
        <Output TaskParameter="FormattedGuidString" PropertyName="FormattedGuidString1" />
        <Output TaskParameter="GuidString" PropertyName="GuidStringItem" />
    </MSBuild.ExtensionPack.Framework.Guid>
    <Message Text="GuidStringItem Crypto: $(GuidStringItem)"/>
    <Message Text="FormattedGuidString Crypto: $(FormattedGuidString1)"/>

    <ItemGroup>
        <FileCollectionToBeDetokenized Include="C:\Code\MSBuildGit\Configuration\TaskExecutorConfigTransforms\App.GREEN.SCRATCH.config"/>
    </ItemGroup>

    <Message text = "BaseUrl        : $(BaseUrl)" />
    <Message text = "DetokenizedTransformFile       : @(FileCollectionToBeDetokenized)" />

    <MSBuild.ExtensionPack.FileSystem.Detokenise TaskAction="Detokenise" TargetFiles="@(FileCollectionToBeDetokenized )"/>


</Target>

4

0 回答 0