将ASP.NET MVC Core应用程序的[部分]发布到Web主机

时间:2018-11-16 17:40:28

标签: c# asp.net asp.net-core-mvc

情况是这样的,我能够通过Visual Studio 2018 FTP发布选项将我的应用程序成功地实时发布到Web主机,并且它可以正确连接并发布它并且更改是可见的。

但是,服务器上存储了一些文件夹,其中包含几个音频文件,因此,每次发布时,音频文件都会被删除,然后重新发布。该过程不仅太长,而且是多余的。并且由于ASP.NET Core将应用程序转换为dll文件,因此它在客户端上速度更快,但是发布更改是一场噩梦,因为必须删除所有文件,包括音频文件夹并重新上传。

csproj文件如下:

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

      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
      </PropertyGroup>

      <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
      </PropertyGroup>

      <ItemGroup>
        <Content Remove="Views\Shared\ExplainPage.cshtml" />
      </ItemGroup>

      <ItemGroup>
        <None Remove="Properties\PublishProfiles\CustomProfile.pubxml" />
        <None Remove="Properties\PublishProfiles\CustomProfile1.pubxml" />
        <None Remove="Properties\PublishProfiles\umaraftab.net - Web Deploy.pubxml" />
      </ItemGroup>

      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />
      </ItemGroup>

      <ItemGroup>
        <Folder Include="Properties\PublishProfiles\" />
        <Folder Include="wwwroot\explanations\" />
        <Folder Include="wwwroot\lectures\" />
      </ItemGroup>

      <ItemGroup>
        <None Include="wwwroot\slick\fonts\slick.svg" />
      </ItemGroup>

    </Project>

wwwroot \ lectures和wwwroot \ explanation文件夹包含音频文件。 有人能建议我如何让音频文件夹在服务器上保持原样,并重新创建dll文件并上传它们,因为这就是所做的更改。

此致

2 个答案:

答案 0 :(得分:0)

您可以从项目中排除这些文件夹。更新.csproj文件以删除以下两行代码:

1- cd /home/usr/scratch/master
2- ./exe /h :4004
3- cd /home/usr/scratch/wrk1
4- ./exe /h host:4004

您可以通过在解决方案资源管理器中右键单击项目节点,然后在Visual Studio中直接在.csproj中进行编辑。

答案 1 :(得分:0)

尝试使用remove关键字替换csproj中的这两个文件夹:

    <Folder Remove="wwwroot\explanations\" />
    <Folder Remove="wwwroot\lectures\" />

在发布过程中,请勿删除目标文件夹中的文件。

相关问题