Mike's profileFreeToDevBlogLists Tools Help

Blog


    June 07

    Braces break %(RecursiveDir) in MSBuild

    Update: 3 December 07 - The RTM version of MSBuild 2008 fixes this issue!

    Summary

    • If braces '()' are in the source path of a file copy operation that uses %(RecursiveDir), then the contents are copied to the root of the destination with no folder structure maintained.

    Scope

    • This affects MSBuild 2005 & MSBuild 2008 (3.5) Beta 1 & Beta 2

    Repro

    • Run the following on VS 2005 (add ToolsVersion="3.5" if running on VS2008)

    <Project DefaultTargets="DeployFiles" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
           <ItemGroup>
                  <FilesToCopy Include="C:\Debug\SomeFolder\**\*.*">
                         <Destination>D:\SomeFolderDebug</Destination>
                  </FilesToCopy>
                  <FilesToCopy Include="C:\Debug (bug)\SomeFolder\**\*.*">
                         <Destination>D:\SomeFolderDebugx86</Destination>
                  </FilesToCopy>
           </ItemGroup>
           <Target Name="DeployFiles">
                  <Copy SourceFiles="%(FilesToCopy.Identity)" DestinationFolder="%(FilesToCopy.Destination)\%(RecursiveDir)"/>
           </Target>
    </Project>

    • The path without braces copies correctly and maintains folder structure.
    • The path with braces places all files into the root destination folder.

    Workaround

    • Use exec and call out to xcopy
    • Write you own copy task!

    Hopefully this gets fixed in Beta 2...FTD

    June 06

    Roll on Windows Server 2008!

    Here is a great video showing the new Virtual Server capabilities: http://soapbox.msn.com/video.aspx?vid=5119240c-6579-4827-8338-7f5539930402

    Highlights:

    • Host 64 bit machines
    • Assign > 3.6Gb RAM
    • Multi-core support
    June 05

    Beware $ in MSBuild 3.5

    In November 2006 I wrote 'Beware $ in MSBuild 1.0'. Working with Visual Studio 2008 Beta 1 which has MSBuild 3.5, I am getting the same unexpected behaviour:

    <Project DefaultTargets="Prepare" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
    <ItemGroup>
    <SomeFiles1 Include="\\OrcasBeta1TFS\c$\AFolder\**\*.*"/>
    <SomeFiles2 Include="\\OrcasBeta1TFS\c%24\AFolder\**\*.*"/>
    <SomeFiles3 Include="\\OrcasBeta1TFS\NewShare\**\*.*"/>
    </ItemGroup>

    <Target Name="Prepare">
    <Copy SourceFiles="@(SomeFiles1)" DestinationFiles="@(SomeFiles1->'c:\SomeFolder1\%(RecursiveDir)%(Filename)%(Extension)')"/>
    <Copy SourceFiles="@(SomeFiles2)" DestinationFiles="@(SomeFiles2->'c:\SomeFolder2\%(RecursiveDir)%(Filename)%(Extension)')"/>
    <Copy SourceFiles="@(SomeFiles3)" DestinationFiles="@(SomeFiles3->'c:\SomeFolder3\%(RecursiveDir)%(Filename)%(Extension)')"/>
    </Target>
    </Project>

    SomeFiles1 – all files will all be copied to SomeFolder1 with no directory structure maintained. This is not expected behaviour !
    SomeFiles2 – the files will be found and the directory structure will be maintained. This is expected behaviour.
    SomeFiles3 – this is a new share mapped to the server path and behaviour will be as for SomeFiles2. This is expected behaviour.

    I did log the bug, though perhaps it hasn't made the cut for the next version of MSBuild... let's wait for Beta 2!...FTD

    June 04

    Microsoft Team Build & MSBuild Desksheet 2.0

    I've made some tweaks to the original Desksheet. If you are new to TeamBuild or MSBuild, then start with the original. The new version is more helpful for those with a bit more experience (though the same forgetful mind!). You can download it here.

    Visual Studio Team & MSBuild Desksheet 2.0

    Note: All this information comes from MSDN. If you are looking for more details, consult the MSBuild reference or forums.

    This will be the last Desksheet for MSBuild 2005. Today Microsoft announced Visual Studio 2008. It will ship around the end of the year and is has a new version of MSBuild (3.5) that introduces some great new features. I'll be putting together a Desksheet for MSBuild 2008 shortly after Beta 2, which is expected in the late summer...FTD