通过 web deploy 发布 .net 网站到IIS

安装web deploy

  1. 参考博客: https://www.jianshu.com/p/519f827b660b
  2. 注意一点: web deploy 官网下载的中文版本是3.6的, 会出现安装不上的情况。请使用英文版的, 4.0版本。

发布时排除文件

  1. 参考: https://cloud.tencent.com/developer/ask/sof/62971
  2. 第二个回答,在发布文件中加入 XML 元素, 亲测有效
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" 
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <PublishFramework />
    <ProjectGuid>afa9f185-7ce0-4935-9da1-ab676229d68a</ProjectGuid>
    <publishUrl>bin\Release\PublishOutput</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
  <ItemGroup>

    <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } -->

    <!-- Copying a file located outside of the project into the published site's wwwroot folder. -->
    <ResolvedFileToPublish Include="..\ReadMe2.md">
      <RelativePath>wwwroot\ReadMe2.md</RelativePath>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </ResolvedFileToPublish>

    <!-- Excluding the wwwroot\Content folder. -->
    <Content Update="wwwroot\Content\**\*" CopyToPublishDirectory="Never" />

    <!-- Excluding the Views\Home\About2.cshtml file. -->
    <Content Update="Views\Home\About2.cshtml" CopyToPublishDirectory="Never" />
  </ItemGroup>
</Project>
posted @ 2023-02-01 14:23  zhoushiya  阅读(41)  评论(0编辑  收藏  举报