Note that there are some explanatory texts on larger screens.

plurals
  1. POCopying build output files, preserving directory structure, gives `Illegal characters in path`
    primarykey
    data
    text
    <p>I am trying to get a MSBuild script to work for building and extracting for deployment a fairly large web application. (We are talking a few thousand files in several dozen directories, here. It's pretty much an inherited, legacy codebase, so not much I can do about it.) The build itself runs fine, but I can't seem to get copying the files to a drop location working properly.</p> <p>Here is a snippet showing what I have in the build script:</p> <pre><code>&lt;PropertyGroup Condition=" '$(UseBuildNumber)' == 'true' "&gt; &lt;ReleaseDirectory&gt;$(ReleaseBaseDirectory)$(ReleaseName)\$(BuildNumber)&lt;/ReleaseDirectory&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;OutputFiles Include=" $(SourceRoot)**\*.aspx; $(SourceRoot)**\*.dll; $(SourceRoot)**\*.gif; $(SourceRoot)**\*.ascx; " /&gt; &lt;/ItemGroup&gt; &lt;Message Text="Output files ==&gt; @(OutputFiles)" /&gt; &lt;Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(ReleaseDirectory)" SkipUnchangedFiles="false" /&gt; </code></pre> <p>I have put a few extra <code>&lt;Message/&gt;</code> in there to verify that the individual paths expand correctly, and both <code>$(SourceRoot)</code> and <code>$(ReleaseDirectory)</code> do indeed have the correct paths. However, in the output, I get (full path elided for brevity):</p> <pre><code>Task "Message" Output files ==&gt; ...\Requirement1866**\*.aspx;...\Requirement1866**\*.dll;...\Requirement1866**\*.gif;...\Requirement1866**\*.ascx Done executing task "Message". </code></pre> <p>Obviously, wildcard expansion has not been performed, and the following <code>Copy</code> then (predictably enough) fails. I'm including only one; in reality this is repeated for each of the file name wildcard patterns (which in turn are many more than I included in the build script snippet above).</p> <pre><code>Using "Copy" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Task "Copy" Copying file from "*basedir*\Requirement1866**\*.aspx" to "*targetdir*\Requirement1866\*buildnumber*\*.aspx". Command: copy /y "*basedir*\Requirement1866**\*.aspx" "*targetdir*\Requirement1866\*buildnumber*\*.aspx" d:\Builds\215\BuildType\TFSBuild.proj(120,5): error MSB3021: Unable to copy file "*basedir*\Requirement1866**\*.aspx" to "*targetdir*\Requirement1866\*buildnumber*\*.aspx". Illegal characters in path. </code></pre> <p>followed by:</p> <pre><code> d:\Builds\215\BuildType\TFSBuild.proj(120,5): error MSB3021: Unable to copy file "*basedir*\Requirement1866**\*.aspx" to "*targetdir*\Requirement1866\*buildnumber*\*.aspx". Illegal characters in path. </code></pre> <p>The only reasonably relevant hit I have come across in my efforts at Googling this was <a href="http://social.msdn.microsoft.com/Forums/sa/msbuild/thread/a611cbb0-ad5d-4c8f-849c-4cbd6bc6db18" rel="noreferrer">Copy Task - Illegal characters in path</a>, but I'm already using an <code>&lt;ItemGroup&gt;</code>, and the <code>&lt;CreateItem&gt;</code> example (adapted) didn't work at all, aborting early with an error saying that <code>TaskParameter</code> was unknown (sorry, I don't have the exact error message in front of me).</p> <p>As a stopgap measure, I could go in and manually copy the relevant files from the build output directory to where I want them, but I want that process to be automated.</p> <p><strong>How do I, then, using MSBuild, copy files which are created during the build process into an output directory, while preserving the relative directory structure, without listing them one by one?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload