ExcludeFromBuild 在 VS2010 Web 部署项目中失败

发布于 2024-10-05 01:55:53 字数 744 浏览 3 评论 0原文

我有一个行为不当的 Web 部署项目。我继承了一个 App_Data 文件夹,其中包含大量 .pdf 文件。某些文件名包含无效字符并且过长。在我的部署项目文件中,我在末尾包含以下 ItemGroup

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

但是当我构建项目时,我不断收到以下错误:

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.

我尝试将通配符添加到 App_Data 文件夹,但它不起作用。我猜想 msbuild 可能无法匹配这些文件以进行排除因为文件名无效。帮助?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不醒的梦 2024-10-12 01:55:53

我在我的部署项目中看到了类似的错误。我相信 VS2010 Web 部署项目有一个错误,该错误会阻止复制任何包含引号字符的文件。

我在这里提交了一个连接错误: https://connect.microsoft.com/VisualStudio/feedback /details/631995/

我知道的唯一解决方法是从文件名中删除引号字符。

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.

素食主义者 2024-10-12 01:55:53

我找到了解决方法!您可以通过将非工作部分替换为 2008 版本中的部分来更改文件“C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets”。为此,请搜索

<Target Name="_CopyBeforeBuild"

xml 标记中的内容并将其替换为以下内容(取自 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文