【发布时间】:2019-12-20 12:09:39
【问题描述】:
我想发布 dotnet 核心程序不使用 Visual Studio。
我使用了dotnet build /p:DeployOnBuild=true /p:PublishProfile=FTP(配置文件 FTP 在 Visual Studio 中没有任何问题)。但是这条命令运行后,FTP 网站上没有文件。我不知道这个命令的细节。所以我使用了 FolderProfile 而不是 FTP 并且效果很好。 Micorsoft Docs 没有 dotnet cli 的 ftp 发布示例。
我的 FTP 配置文件像这样:
<?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>
dotnet cli ftp 发布有解决方案吗?
命令dotnet build -v n /p:DeployOnBuild=true /p:PublishProfile=FTP :
结尾:
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)
【问题讨论】:
-
将详细级别设置为详细:
dotnet build -v d /p:DeployOnBuild=true /p:PublishProfile=FTP并重试。然后与我们分享命令行中写入的内容。请将输出放到您的原始帖子中。 -
感谢您的帮助!命令信息被更新。而且我发现该命令没有运行任何关于 ftp 的内容。
-
根据您的输出,它仅发布到本地目录
.\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` 没有正确引用您的 pubxml 文件。尝试引用包含其相对路径的 pubxml 文件,如下所示:/p:PublishProfile=FTP\Properties\PublishProfiles\FTP.pub.xml。请确保在解决方案所在的路径中执行dontnet build ...。 -
我使用了与 FTP 配置文件具有相同目录的文件夹配置文件。它运作良好。该命令与 .csproj 文件位于同一目录中。
-
<EnvironmentName>Test</EnvironmentName>是一个特殊的环境变量。我可以在已发布的临时目录中找到它。<environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Test" /> </environmentVariables>web.config
标签: c# .net-core ftp dotnet-cli