MSBuild 执行目标 WebDirectoryCreate 时出错

发布于 2024-12-09 14:47:04 字数 2208 浏览 1 评论 0原文

我正在尝试使用 MSBuildCommunityTasks 中的 WebDirectoryCreate 任务来创建我的虚拟目录使用 MSBuild 但它会抛出 Index was out of range 错误。

这是我的构建脚本的相关部分:

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  ...other build targets working ok...

  <Target Name="Deploy">
    <RemoveDir Directories="$(DeploymentFolder)$(VerRevision)" ContinueOnError="true" />
    <ItemGroup>
      <DeploymentFiles Include="$(PublishOutputFolder)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(DeploymentFiles)" DestinationFolder="$(DeploymentFolder)$(VerRevision)\%(RecursiveDir)" />
    <WebDirectoryDelete VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" ContinueOnError="true" />
    <WebDirectoryCreate VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" VirtualDirectoryPhysicalPath="$(DeploymentFolder)$(VerRevision)" />
  </Target>

这是相应的输出:

  Deleting virtual directory 'MyApp283' on 'localhost:80'.
MSBUILD : warning : The system cannot find the path specified. (Exception from HRESULT: 0x80070003) [D:\build\MyApp\Build.xml]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "WebDirectoryDelete" is set to "true".
  Creating virtual directory named MyApp283 on localhost:
D:\build\MyApp\Build.xml(50,5): error : Index was out of range. Must be non-negative and less than the size of the collection.
D:\build\MyApp\Build.xml(50,5): error : Parameter name: index
Done Building Project "D:\build\MyApp\Build.xml" (default targets) -- FAILED.

Build FAILED.

我通过手动添加虚拟目录并运行构建来检查导入是否正确。在这种情况下,WebDirectoryDe​​lete 任务正确删除虚拟目录,但 WebDirectoryCreate 抛出相同的错误。

我正在使用 MSBuild 从一个简单的批处理文件执行构建。在此任务之前的所有任务都执行得很好。操作系统为Windows Server 2008 R2企业版SP1。

谁能给我任何线索吗? SO 和 Google 抛出了一个链接没有答案。

I'm trying to use the WebDirectoryCreate task from the MSBuildCommunityTasks to create my virtual directory with MSBuild but it throws an Index was out of range error.

Here's the relevant part of my build script:

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  ...other build targets working ok...

  <Target Name="Deploy">
    <RemoveDir Directories="$(DeploymentFolder)$(VerRevision)" ContinueOnError="true" />
    <ItemGroup>
      <DeploymentFiles Include="$(PublishOutputFolder)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(DeploymentFiles)" DestinationFolder="$(DeploymentFolder)$(VerRevision)\%(RecursiveDir)" />
    <WebDirectoryDelete VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" ContinueOnError="true" />
    <WebDirectoryCreate VirtualDirectoryName="$(VirtualDirectory)$(VerRevision)" VirtualDirectoryPhysicalPath="$(DeploymentFolder)$(VerRevision)" />
  </Target>

And here's the corresponding output:

  Deleting virtual directory 'MyApp283' on 'localhost:80'.
MSBUILD : warning : The system cannot find the path specified. (Exception from HRESULT: 0x80070003) [D:\build\MyApp\Build.xml]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "WebDirectoryDelete" is set to "true".
  Creating virtual directory named MyApp283 on localhost:
D:\build\MyApp\Build.xml(50,5): error : Index was out of range. Must be non-negative and less than the size of the collection.
D:\build\MyApp\Build.xml(50,5): error : Parameter name: index
Done Building Project "D:\build\MyApp\Build.xml" (default targets) -- FAILED.

Build FAILED.

I have checked the import is correct by adding the virtual directory manually and running the build. In this case the WebDirectoryDelete task corrcetly deletes the virtual directory but WebDirectoryCreate throws the same error.

I'm executing the build using MSBuild from a simple batch file. All tasks before this one execute just fine. OS is Windows Server 2008 R2 Enterprise Edition SP1.

Can anyone give me any clues? SO and Google threw up one single link with no answer.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文