开发者

ExcludeFromBuild failing in VS2010 web deployment project

开发者 https://www.devze.com 2023-01-27 03:25 出处:网络
I have a web deployment project that is misbehaving. I have inherited an App_Data folder that contains a substantial number of .pdf files. Some of the filenames include invalid characters and are over

I have a web deployment project that is misbehaving. I have inherited an App_Data folder that contains a substantial number of .pdf files. Some of the filenames include invalid characters and are overly long. In my deployment project file I include the following ItemGroup at the end:

...
  <ItemGroup>
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.pdf" />
  </ItemGroup>
</Project>

But when I build the project I keep开发者_JAVA技巧 getting the following error:

error : Copying file $([System.IO.Path]::Combine($(_WDPSourceWebPhysicalPath),
  App_Data\CWM2\393S097 Connection of an Embedded Network to elided's Network v1.pdf))
  to obj\Debug\Source\App_Data\CWM2\393S097 Connection of an Embedded Network to
  elided's Network v1.pdf failed. The path is not of a legal form.

I've tried adding wildcards to the App_Data folder but it's just not working. I guess it's conceivable that msbuild is unable to match those files for exclusion because the filename is invalid. Help?


I've seen a similar bug with my deployment project. I believe that VS2010 Web Deployment Projects has a bug that prevents copying any file that contains a quote character.

I filed a connect bug here: https://connect.microsoft.com/VisualStudio/feedback/details/631995/

The only workaround I know is to remove the quote character from the name of the file.


I found a workaround! you can change the file "C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets" by replacing the non working part with the one from the 2008 version. To do that, search for

<Target Name="_CopyBeforeBuild"

and replace the content in the xml tag with the following (taken from webdeploymentproject 2008)

<Target Name="_CopyBeforeBuild" Condition=" '$(EnableCopyBeforeBuild)' == 'true' or '@(ExcludeFromBuild)' != ''  ">
    <CreateItem Include="$(SourceWebPhysicalPath)\**\*.*" Exclude="@(ExcludeFromBuild)">
        <Output ItemName="_WebFiles" TaskParameter="Include" />
    </CreateItem>

    <RemoveDir Directories="$(CopyBeforeBuildTargetPath)"/>
    <MakeDir Directories="$(CopyBeforeBuildTargetPath)"/>
    <Copy SourceFiles="@(_WebFiles)" DestinationFolder="$(CopyBeforeBuildTargetPath)\%(_WebFiles.SubFolder)%(_WebFiles.RecursiveDir)" />

    <CreateProperty Value="$(CopyBeforeBuildTargetPath)">
        <Output TaskParameter="Value" PropertyName="_AspNetCompilerSourceWebPath" />
    </CreateProperty>
</Target>
0

精彩评论

暂无评论...
验证码 换一张
取 消