0

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)
minskiter
  • 73
  • 1
  • 7
  • 1
    Set the verbosity Level to detailed: `dotnet build -v d /p:DeployOnBuild=true /p:PublishProfile=FTP` and try again. Then share with us what is written into the commandline. Please put the output to your original post. – Aedvald Tseh Dec 20 '19 at 12:21
  • Thank for you help! The command infomation is updated. And I find that the command doesn't run anything about ftp. – minskiter Dec 20 '19 at 15:52
  • According to your output it only published to local directory `.\obj\Release\netcoreapp2.2\PubTmp\Out\`. It does not attempt to publish to an FTP-Server. The reason for this might be that `/p:PublishProfile=FTP` does not properly reference your pubxml-file. Try referencing the pubxml-file including its relative path like so: `/p:PublishProfile=FTP\Properties\PublishProfiles\FTP.pub.xml`. Please make sure that you execute `dontnet build ...` in the path where the solution is. – Aedvald Tseh Dec 21 '19 at 16:57
  • I used the Folder profile with the same directory as FTP proflie. And It works well. The command wokrs in same directory as the .csproj file. – minskiter Dec 22 '19 at 02:36
  • ```Test ``` It is a special environment variable. I can find it in the published temporary directory. ``` ``` web.config – minskiter Dec 22 '19 at 02:41
  • @Minskiter Did you find solution for this? I am facing the same issue. And how you connected to FTP using FolderProfile? – Tech Yogesh Jul 01 '20 at 05:35

1 Answers1

1

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

dino
  • 58
  • 6