Search code examples
c#.net-coreftpdotnet-cli

How to publish dotnet core web back-end by FTP?


I want to publish dotnet core program without using Visual Studio.
I used dotnet build /p:DeployOnBuild=true /p:PublishProfile=FTP(The profile FTP works without any issues in Visual Studio). But there is no file in the FTP website after this command runs. I don't know the details for this command. So I used the FolderProfile instead of the FTP and it works good. Micorsoft Docs don't have the example for ftp publish by dotnet cli.
MY FTP profile like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FTP</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>**.**.**.**\api</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <ProjectGuid>28bdbda4-4eb1-4b10-b5bd-d150e6d9****</ProjectGuid>
    <publishUrl>ftp://**.**.**.**</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <FtpPassiveMode>True</FtpPassiveMode>
    <FtpSitePath></FtpSitePath>
    <UserName>webadmin</UserName>
    <_SavePWD>True</_SavePWD>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <SelfContained>false</SelfContained>
    <EnvironmentName>Test</EnvironmentName>
  </PropertyGroup>
</Project>

Is there a solution for ftp publish by dotnet cli?


the command dotnet build -v n /p:DeployOnBuild=true /p:PublishProfile=FTP : end with:

1>Project "FTPTest.sln" on node 1 (Restore target(s)).     
1>ValidateSolutionConfiguration:         
Building solution configuration "Debug|Any CPU".       
Restore:         
Committing restore...         
Assets file has not changed. Skipping assets file writing. 
Path: FTPTest\obj\project.assets.json         
Restore completed in 51.54 ms for FTPTest.csproj.         
NuGet Config files used:             
C:\Users\*******\AppData\Roaming\NuGet\NuGet.Config             
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config         
Feeds used:             
https://api.nuget.org/v3/index.json             
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\     
1>Done Building Project "FTPTest.sln" (Restore target(s)).   
1:2>Project "FTPTest.sln" on node 1 (default targets).     
1>ValidateSolutionConfiguration:         
Building solution configuration "Debug|Any CPU".   
1:2>Project "FTPTest.sln" (1:2) is building 
2>GenerateTargetFrameworkMonikerAttribute:       
Skipping target 
"GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.       
_CoreGenerateRazorAssemblyInfo:       
Skipping target "_CoreGenerateRazorAssemblyInfo" 
because all output files are up-to-date with respect to the input files.      
CoreGenerateAssemblyInfo:       
Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.       
CoreCompile:       
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.       
_CopyOutOfDateSourceItemsToOutputDirectory:       
Skipping target 
"_CopyOutOfDateSourceItemsToOutputDirectory" because all output files are up-to-date with respect to the input files.       
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:         
GenerateBuildDependencyFile:       
Skipping target "GenerateBuildDependencyFile" because all output files are up-to-date with respect to the input files.       
GenerateBuildRuntimeConfigurationFiles:       
Skipping target "GenerateBuildRuntimeConfigurationFiles" because all output files are up-to-date with respect to the input files.       
CopyFilesToOutputDirectory:         
FTPTest -> .\bin\Debug\netcoreapp2.2\**********.dll       
_DeletePublishIntermediateOutputPath:
......some details......
 Publish:
         FTPTest -> .\obj\Release\netcoreapp2.2\PubTmp\Out\
         No web.config found. Creating '.\obj\Release\netcoreapp2.2\PubTmp\Out\web.config'
     2>Done Building Project ".\*******.csproj" (default targets).
     1>Done Building Project "********.sln" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Solution

  • Try find more information here: https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli