为什么MsbuildExtension Detokenise类重新加载项目?

时间:2012-04-25 17:28:14

标签: msbuild msbuild-task msbuildcommunitytasks msbuildextensionpack

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

进一步说明:我将属性传递给项目文件。此属性是.props文件的路径。它包含令牌类的标记和替换值。该任务显然重新加载项目,并且不维护路径。其他任务似乎不是这种情况,例如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>

0 个答案:

没有答案