views:

94

answers:

1

I am having some trouble with a MSBuild file that I am trying to compile some custom libraries.

<PropertyGroup>
    <FullVersion>10.8.0.0</FullVersion>
</PropertyGroup>

<ItemGroup>
    <LibsToBuild Include=".\Lib1">
        <Bin>bin\*.*</Bin>
        <Project>Library 1</Project>
        <Build>ReleaseNoProtect</Build>
        <Version>CurrentVersion</Version>
    </LibsToBuild>

    <LibsToBuild Include=".\Lib2">
        <Bin>bin\*.*</Bin>
        <Project>Library 2</Project>
        <Build>ReleaseLibrary</Build>
        <Version>CurrentVersion</Version>
    </LibsToBuild>      
</ItemGroup>

<ItemGroup>    
    <LibsToCopy Include="@(LibsToBuild->'%(FullPath)\%(Version)\%(Bin)')" />
</ItemGroup>

<Target Name="BuildLibs">
    <MSBuild
        Projects="@(LibsToBuild->'%(FullPath)\%(Version)\Build\Build.proj')"
        Targets="%(LibsToBuild.Build)"
        Properties="Configuration=Release;APP_VERSION=$(FullVersion);PROJECT_NAME=%(LibsToBuild.Project)"
    />

    <Copy
        SourceFiles="@(LibsToCopy)"
        DestinationFiles="@(LibsToCopy->'.\Libraries\CurrentVersion\%(RecursiveDir)%(Filename)%(Extension)')"
    />

    <!--
    <Exec Command='xcopy /y @(LibsToCopy) .\Libraries\CurrentVersion' />
    -->
</Target>

When I run this through MSBuild, all of the compiles work, but the copy files does not. MSBuild complains with the following errors:

Copying file from "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*".
X:\Projects\Test Release.build(35,3): error MSB3021: Unable to copy file "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*". Illegal characters in path.
Copying file from "X:\Projects\Lib2\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*".
X:\Projects\Test Release.build(35,3): error MSB3021: Unable to copy file "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*". Illegal characters in path.

I am unable to figure out why the transform in the "LibsToCopy" ItemGroup isn't expanding the filename wildcards.

I have also attempted to use xcopy, but it doesn't like the wildcards either.

Thanks! Dave

A: 

I had a similar problem. Try this, just before the <Copy> task

<CreateItem Include="@(LibsToBuild->'%(FullPath)\%(Version)\%(Bin)')">
  <Output TaskParameter="Include" ItemName="LibsToCopy" />
</CreateItem>

Unfortunately the documentation says CreateItem task is deprecated, so I don't know how to solve tis problem in the future.

Romano
Thanks Romano! That worked great. If anyone has an explanation for why my original version doesn't work, I'd appreciate it. I'd hate for my build to break one day in the future because MS decided to finally eliminate CreateItem.
DaveNay
Those WildCards arent going to be expanded in Metadata, you have to create an item then they will be expanded.
Sayed Ibrahim Hashimi
CreateItem is deprecated in .NET > 2. You could directly create your item with an ItemGroup in your target in .NET > 2
madgnome