Invalid character or TextString not found ?

Feb 10, 2010 at 9:17 AM

 

Hi,

I have been trying all the possibilities to use the TextString task, but I get stuck to either this error :

error MSB5016: The name "MSBuild.ExtensionPack.Framework.TextString" contains an invalid character ".".

or

error MSB4066: The attribute "TaskAction" in element <TextString> is unrecognized.

The first time, I have this : 

 

<PropertyGroup>
    <ExtensionTasksPath Condition="'$(ExtensionTasksPath)' == ''">..\msbuild\ExtensionPack\</ExtensionTasksPath>
    <PreBuildEvent>call "$(SolutionDir)\splitter.bat" "$(ProjectDir)" $(ConfigurationName)</PreBuildEvent>
    
  </PropertyGroup>
  <Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks" />
  
  <PropertyGroup>
    <MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="MyComms">
      <Output TaskParameter="Result" PropertyName="isTrue" />
    </MSBuild.ExtensionPack.Framework.TextString>
    <Application Condition="$(isTrue)">Case1</Application>
  </PropertyGroup>

The second time, I have this :

 

<PropertyGroup>
    <ExtensionTasksPath Condition="'$(ExtensionTasksPath)' == ''">..\msbuild\ExtensionPack\</ExtensionTasksPath>
    <PreBuildEvent>call "$(SolutionDir)\splitter.bat" "$(ProjectDir)" $(ConfigurationName)</PreBuildEvent>
    
  </PropertyGroup>
  <Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks" />
  
  <PropertyGroup>
    <TextString TaskAction="StartsWith" String1="$(ConfigurationName)" String2="MyComms">
      <Output TaskParameter="Result" PropertyName="isComms" />
    </TextString>
    <Application Condition="$(isComms)">MyComms</Application>
  </PropertyGroup>

Any Idea ?

Thanks,

Nicolas Penin

 

 

Coordinator
Feb 10, 2010 at 10:38 AM

Hi

 

You cant use a task ina  propertygroup. Try this rather

 

    <Target Name="Default">
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="MyComms2" String2="MyComms">
            <Output TaskParameter="Result" PropertyName="isTrue" />
        </MSBuild.ExtensionPack.Framework.TextString>
        <PropertyGroup>
            <Application Condition="$(isTrue)">Case1</Application>
        </PropertyGroup>
        <Message Text="APP: $(Application)"/>
    </Target>

 

    <Target Name="Default">
        <MSBuild.ExtensionPack.Framework.TextString TaskAction="StartsWith" String1="MyComms2" String2="MyComms">
            <Output TaskParameter="Result" PropertyName="isTrue" />
        </MSBuild.ExtensionPack.Framework.TextString>
        <PropertyGroup>
            <Application Condition="$(isTrue)">Case1</Application>
        </PropertyGroup>
        <Message Text="APP: $(Application)"/>
    </Target>

 

 

 

Feb 10, 2010 at 12:13 PM

Hi,

If I do so, it tells me it does not recognize the task. There is one thing I did not mentionned : I am not really in a true msbuild file, this is a csproj. Do you know where I should use them in csproj ?

Coordinator
Feb 10, 2010 at 12:25 PM

csproj is fine.

1. Import the Task so msbuild can find it. if you installed to the default location, then this is <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>

2. Override a target in your csproj file, e.g. AfterCompile. It really depends on what you need done when. If you load you csproj file in MSBuild Explorer (www.msbuildexplorer.com) you will see all the available targets.

 

Mike

Feb 10, 2010 at 12:31 PM

msBuild Explorer cannot open my project : it tells me it cannot find C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets.

It does not exists because I am on an x64 and that file is in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets.

I would say this is because the variable MSBuildExtensionsPath is not properly set in msbuildexplorer x64...

 

Thanks a lot for your help

Coordinator
Feb 10, 2010 at 1:20 PM

You need to install the 32 bit version of MSBUild explorer because you are targeting 32 bit software.