编辑: 我注意到在bin\Debug\net461\Publish文件夹中有所有必需的内容,我尝试检查使用这种方式的配置:
#if DEBUG
ViewData["Message"] = "DEBUG";
#else
ViewData["Message"] = "else";
#endif
网页显示“DEBUG”... 原始问题: ASP.Net Core发布了一个空文件夹:我在ASP.Net中没有这个问题,只有在ASP.Net Core中才有。所以这是我如何在两个平台上创建我的发布配置文件的方式:
创建配置文件 => 文件夹 => bin\Release\PublishOutput => 创建配置文件 => 发布
使用Asp.Net它会生成这个.pubxml文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>bin\Release\PublishOutput</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
使用Asp.Net输出:
2>Web App was published successfully file:///Path/bin/Release/PublishOutput
2>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
使用Asp.Net Core生成的.pubxml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>32b7ffef-9cf4-471a-ab1a-ec3c69d0dd13</ProjectGuid>
<publishUrl>bin\Release\PublishOutput</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
使用 Asp.Net Core 输出:
Web App was published successfully file:///Path/bin/Release/PublishOutput
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
我在3台电脑上尝试过,但使用Asp.Net Core仍然得到了一个空文件夹。
cd
到你的.csproj
或.sln
所在的目录,然后在你喜欢的终端中运行dotnet publish -c Release -o "path/to/output"
。 - mausworks