如何使用 MSBuild Extension Pack 创建包含应用程序的网站

发布于 2024-08-08 20:12:05 字数 1644 浏览 1 评论 0原文

使用 MSBuild 扩展包 创建网站的正确方法是什么?

我正在尝试使用 MSBuild 扩展包 使用以下目标创建网站。不幸的是我的语法不正确。该目标将抛出异常“InvalidOperationException:指定的路径已存在。\r”。这是添加应用程序后的情况。

我通过更改 WebApplication 项或 VirtualDirectory 项尝试了以下目标的几个不同版本。如果我将 WebApplication 项的 Include 属性更改为“/”以外的其他内容,则创建将起作用。虽然网站创建后我无法启动它,因为 COM 错误 0x800710D8。 (对象标识符不代表有效对象)

<Target Name="ProvisionIIS7WebSite" DependsOnTargets="CreateDeploymentNumber">
  <PropertyGroup>
    <WebSiteName>$(BaseDeploymentName)$(DeploymentNumber)</WebSiteName>
    <PortNumber>$(DeploymentNumber)</PortNumber>
  </PropertyGroup>

  <ItemGroup>
    <WebApplication Include="/">
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </WebApplication>
    <VirtualDirectory Include="/">
      <ApplicationPath>/</ApplicationPath>
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </VirtualDirectory>
  </ItemGroup>

  <!-- Create new site -->
  <MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Create"
    Name="$(WebSiteName)"
    Port="$(PortNumber)"
    Path="$(WebSitePath)"
    AppPool="$(WebSiteAppPool)"
    Applications="@(WebApplication)"
    VirtualDirectories="@(VirtualDirectory)">
    <Output TaskParameter="SiteID" PropertyName="WebSiteID" />
  </MSBuild.ExtensionPack.Web.Iis7Website>
  <Message Text="Created website with ID $(WebSiteID)" />
</Target>

What is the correct way to create a web site using the MSBuild Extension Pack?

I'm trying to use the MSBuild Extension Pack to create a web site using the following target. Unfortunately I don't have the syntax correct. This target will throw an exception saying "InvalidOperationException: The specified path already exists.\r". This is after adding the application.

I've tried several different versions of the below target by changing the WebApplication item or the VirtualDirectory item. If I change the Include attribute for the WebApplication item to be something other than "/" then the creation will work. Although once the web site is created I can't start it because of COM error 0x800710D8. (The object identifier does not represent a valid object)

<Target Name="ProvisionIIS7WebSite" DependsOnTargets="CreateDeploymentNumber">
  <PropertyGroup>
    <WebSiteName>$(BaseDeploymentName)$(DeploymentNumber)</WebSiteName>
    <PortNumber>$(DeploymentNumber)</PortNumber>
  </PropertyGroup>

  <ItemGroup>
    <WebApplication Include="/">
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </WebApplication>
    <VirtualDirectory Include="/">
      <ApplicationPath>/</ApplicationPath>
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </VirtualDirectory>
  </ItemGroup>

  <!-- Create new site -->
  <MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Create"
    Name="$(WebSiteName)"
    Port="$(PortNumber)"
    Path="$(WebSitePath)"
    AppPool="$(WebSiteAppPool)"
    Applications="@(WebApplication)"
    VirtualDirectories="@(VirtualDirectory)">
    <Output TaskParameter="SiteID" PropertyName="WebSiteID" />
  </MSBuild.ExtensionPack.Web.Iis7Website>
  <Message Text="Created website with ID $(WebSiteID)" />
</Target>

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

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

发布评论

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

评论(1

趁微风不噪 2024-08-15 20:12:05

您需要一个有效的别名,才能尝试

  <ItemGroup>
    <WebApplication Include="/MyApp">
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </WebApplication>
    <VirtualDirectory Include="/MyVdir">
      <ApplicationPath>/MyApp</ApplicationPath>
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </VirtualDirectory>
  </ItemGroup>

此处进一步讨论

You need a valid alias, to try

  <ItemGroup>
    <WebApplication Include="/MyApp">
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </WebApplication>
    <VirtualDirectory Include="/MyVdir">
      <ApplicationPath>/MyApp</ApplicationPath>
      <PhysicalPath>$(WebSitePath)</PhysicalPath>
    </VirtualDirectory>
  </ItemGroup>

Discussed further here

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