zoukankan      html  css  js  c++  java
  • ASP.NET Core 2.0 MVC 发布部署--------- ASP.NET Core 发布的具体操作

    ASP.NET Core 发布的具体操作

    下面使用C# 编写的ASP.NET Core Web项目示例说明发布的全过程。

    1创建项目

    选择文件” > “新建” > “项目 添加新项目对话框中,在已安装 “Visaul C#”  “Web” 项目类型窗格中选择“ASP.NET Core Web 应用程序,在名称文本框中输入项目名称如MmPS”,点击 确定(如下图1),然后在中心窗格中选择“Web应用程序(模型视图控制器)模板, 然后选择确定按钮(如下图2

    1

    2

    2、添加Web项目应用程序的源代码的各种逻辑

    本项目是已经建好的,无需创建。此步骤省略。

    3、发布Web项目

    发布已经完善的Web项目应用程序,首先是定义应用的目标平台。

    1、编辑项目资源

    解决方案资源管理器中右键单击项目(而非解决方案),然后选择编辑 MmPS.csproj”。在MmPS.csproj文件(该文件用于定义应用的目) <PropertyGroup> 部分中添加<RuntimeIdentifiers> 标记,然后指定每个目标平台的运行时标识符 (RID) 请注意,如果是多个系统,还需要添加分号来分隔 RID 不同系统的RID会不同,具体请查看运行时标识符目录,获取运行时标识符列表。例如,以下示例表明应用在 64 Windows 10 操作系统和 64 OS X 10.11 版本的操作系统上运行。

    MmPS.csproj文件中添加

    <PropertyGroup>     <RuntimeIdentifiers>ubuntun.16.04-x64;osx.10.11-x64

    </RuntimeIdentifiers>

    </PropertyGroup>

    2发布应用

    调试并测试程序后,为应用的每个目标平台创建要与应用一起发布的文件。从Visual Studio发布应用,执行以下操作:

    解决方案资源管理器中右键单击项目(而非解决方案),然后选择发布,如下图3

    发布选项卡上,选择发布 Visual Studio将包含应用程序的文件写入本地文件系统。发布选项卡现在显示单个配置文件 FolderProfile 该配置文件的配置设置显示在选项卡的摘要部分。目标运行时用于标识已发布的运行时,目标位置用于标识独立部署文件的写入位置。

    默认情况下,Visual Studio 将所有已发布文件写入单个目录。 为了方便起见,最好为每个目标运行时创建单个配置文件,并将已发布文件置于特定于平台的目录中。 这包括为每个目标平台创建单独的发布配置文件。 

    l 根据平台单独发布应用程序

    现在执行下列操作,为每个平台重新生成应用程序:

    1发布对话框中选择创建新配置文件

    选取发布目标对话框中,将选择文件夹位置更改为 binReleasePublishOutputubuntun.16.04-x64 选择确定

    在配置文件列表中选择新配置文件 (FolderProfile1) ,并确保目标运行时 ubuntun.16.04-x64 如果不是,请选择设置 配置文件设置对话框中,将目标运行时更改为 ubuntun.16.04-x64,然后选择保存 否则,选择取消

    2选择发布,发布 64 ubuntun.16.04平台的应用。

    3、其他平台类似操作即可

    再次按照上述步骤创建 osx.10.11-x64 平台的配置文件。 “目标位置binReleasePublishOutputosx.10.11-x64目标运行时 osx.10.11-x64Visual Studio 分配给此配置文件的名称是 FolderProfile2

    请注意,每个目标位置中都包含启动应用所需的完整文件集(既包含应用文件,又包含所有 .NET Core 文件)。同时与应用程序的文件一起,发布过程将发出包含应用调试信息的程序数据库 (.pdb) 文件。 该文件主要用于调试异常。 可以选择不使用应用程序文件打包该文件。 但是,如果要调试应用的发布版本,则应保存该文件。

    4、可以把已经发布的文件部署到其他系统中了, 例如,可以使用简单的 copy 命令将其打包为 Zip 文件,或者使用选择的安装包进行部署下面会把发布的文件部署到ubuntun.16.04-x64)

    下面是项目完整的 MmPS.csproj 文件。

    <Project Sdk="Microsoft.NET.Sdk.Web">

      <PropertyGroup Label="Globals">

        <SccProjectName>SAK</SccProjectName>

        <SccProvider>SAK</SccProvider>

        <SccAuxPath>SAK</SccAuxPath>

        <SccLocalPath>SAK</SccLocalPath>

      </PropertyGroup>

      <PropertyGroup>

        <TargetFramework>netcoreapp2.0</TargetFramework>

        <RuntimeIdentifiers>ubuntun.16.04-x64;osx.10.11-x64</RuntimeIdentifiers>

      </PropertyGroup>

      <ItemGroup>

        <Compile Remove="Modelsauthority.cs" />

        <Compile Remove="Modelslog.cs" />

        <Compile Remove="Modelsmenu.cs" />

        <Compile Remove="Modelsmodule.cs" />

        <Compile Remove="Models odes.cs" />

        <Compile Remove="Models oles.cs" />

        <Compile Remove="Modelssource.cs" />

        <Compile Remove="ModelsTestUser.cs" />

        <Compile Remove="Modelsuser.cs" />

        <Compile Remove="Modelsuserinrole.cs" />

      </ItemGroup>

      <ItemGroup>

        <Content Remove="appsettings.Development.json" />

        <Content Remove="ViewsIndex.cshtml" />

      </ItemGroup>

      <ItemGroup>

        <None Remove="ModelsMMPS.txt" />

        <None Remove="PropertiesPublishProfilesCustomProfile.pubxml" />

        <None Remove="ViewsLog.js" />

        <None Remove="ViewsLogLog.js" />

        <None Remove="ViewsOrganizationInfoOrganizationInfo.js" />

        <None Remove="ViewsUpdateUpdateUpload.js" />

      </ItemGroup>

      <ItemGroup>

        <Content Include="ViewsDeviceDevice.js" />

        <Content Include="ViewsLogLog.js" />

        <Content Include="ViewsMenuMenu.js" />

        <Content Include="ViewsOrganizationInfoOrganizationInfo.js" />

        <Content Include="ViewsRolesRoles.js" />

        <Content Include="ViewsSourceSource.js">

          <CopyToOutputDirectory>Never</CopyToOutputDirectory>

        </Content>

        <Content Include="ViewsUpdateUpdateUpload.js" />

        <Content Include="ViewsUserInfoUserInfo.js">

          <CopyToOutputDirectory>Never</CopyToOutputDirectory>

        </Content>

      </ItemGroup>

      <ItemGroup>

        <PackageReference Include="AutoMapper" Version="6.1.1" />

        <PackageReference Include="Dapper" Version="1.50.2" />

        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />

        <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.0" />

        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />

        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />

        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />

        <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />

        <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />

        <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />

        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />

        <PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.8-dmr" />

        <PackageReference Include="NETStandard.Library" Version="2.0.0" />

        <PackageReference Include="newtonsoft.json" Version="10.0.3" />

        <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.0-rtm-10062" />

        <PackageReference Include="System.ComponentModel" Version="4.3.0" />

      </ItemGroup>

      <ItemGroup>

        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />

      </ItemGroup>

      <ItemGroup>

        <None Include="wwwrootjskindeditorkindeditor-all-min.js" />

        <None Include="wwwrootjskindeditorkindeditor-all.js" />

        <None Include="wwwrootjskindeditorlangar.js" />

        <None Include="wwwrootjskindeditorlangen.js" />

        <None Include="wwwrootjskindeditorlangko.js" />

        <None Include="wwwrootjskindeditorlang u.js" />

        <None Include="wwwrootjskindeditorlangzh-CN.js" />

        <None Include="wwwrootjskindeditorlangzh-TW.js" />

        <None Include="wwwrootjskindeditorpluginsanchoranchor.js" />

        <None Include="wwwrootjskindeditorpluginsautoheightautoheight.js" />

        <None Include="wwwrootjskindeditorpluginsaidumapaidumap.js" />

        <None Include="wwwrootjskindeditorpluginsclearhtmlclearhtml.js" />

        <None Include="wwwrootjskindeditorpluginscodecode.js" />

        <None Include="wwwrootjskindeditorpluginscodeprettify.js" />

        <None Include="wwwrootjskindeditorpluginsemoticonsemoticons.js" />

        <None Include="wwwrootjskindeditorpluginsfilemanagerfilemanager.js" />

        <None Include="wwwrootjskindeditorpluginsfixtoolbarfixtoolbar.js" />

        <None Include="wwwrootjskindeditorpluginsflashflash.js" />

        <None Include="wwwrootjskindeditorpluginsimageimage.js" />

        <None Include="wwwrootjskindeditorpluginsinsertfileinsertfile.js" />

        <None Include="wwwrootjskindeditorpluginslineheightlineheight.js" />

        <None Include="wwwrootjskindeditorpluginslinklink.js" />

        <None Include="wwwrootjskindeditorpluginsmapmap.js" />

        <None Include="wwwrootjskindeditorpluginsmediamedia.js" />

        <None Include="wwwrootjskindeditorpluginsmultiimageimagesswfupload.swf" />

        <None Include="wwwrootjskindeditorpluginsmultiimagemultiimage.js" />

        <None Include="wwwrootjskindeditorpluginspagebreakpagebreak.js" />

        <None Include="wwwrootjskindeditorpluginsplainpasteplainpaste.js" />

        <None Include="wwwrootjskindeditorpluginspreviewpreview.js" />

        <None Include="wwwrootjskindeditorpluginsquickformatquickformat.js" />

        <None Include="wwwrootjskindeditorplugins able able.js" />

        <None Include="wwwrootjskindeditorplugins emplate emplate.js" />

        <None Include="wwwrootjskindeditorpluginswordpastewordpaste.js" />

      </ItemGroup>

      <ItemGroup>

        <ProjectReference Include="..DownloadHelperDownloadHelper.csproj" />

        <ProjectReference Include="..MmPS.ApplicationMmPS.Application.csproj" />

        <ProjectReference Include="..MmPS.Common.DataMmPS.Common.Data.csproj" />

        <ProjectReference Include="..MmPS.EntityFrameworkCoreMmPS.EntityFrameworkCore.csproj" />

      </ItemGroup>

      <ItemGroup>

        <Folder Include="PropertiesPublishProfiles" />

      </ItemGroup>

      <ItemGroup>

        <Content Update="wwwrootjsviewssource.js">

          <CopyToOutputDirectory>Never</CopyToOutputDirectory>

        </Content>

        <Content Update="wwwrootjsviewsuserInfo.js">

          <CopyToOutputDirectory>Never</CopyToOutputDirectory>

        </Content>

      </ItemGroup>

      <ProjectExtensions><VisualStudio><UserProperties bower_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>

    </Project>

  • 相关阅读:
    epoll的LT和ET模式
    linux搭建java环境
    【第三方SDK】百度地图实现最简单的定位功能(无地图界面)
    闲云控制台(二)查看文件功能,支持十六进制查看文件
    ios8 swift开发:显示变量的类名称
    cocos2dx的runAction: 反复运行,多个动作连接运行,多个动作同一时候运行的实现
    myeclipse设置凝视
    2-06. 数列求和(20)(ZJUPAT 数学)
    【IPC进程间通信之四】数据复制消息WM_COPYDATA
    条件熵定义推导公式
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/8329707.html
Copyright © 2011-2022 走看看