【发布时间】:2018-11-13 02:08:41
【问题描述】:
更新 1
根据@Priyesh Kumar 的反馈,我使用了网站根文件夹中的以下命令(带有 *.csproj 的网站)。这行得通。然后我将“win10-x64”内容文件复制到 c:\www\sigex.com。
dotnet publish -c Release -r win10-x64 --self-contained
我现在遇到了一些不同的问题,但会修复它们,然后发回解决方案。
原帖
您好,我正在尝试将我的网站本地发布到 IIS(我在 IIS 管理器中创建的网站)。我在visual studio中使用右键发布选项。
在 IIS 管理器中,我的设置是;
对于应用程序池,我有以下内容
当我单击“发布”并选择“IIS、FTP 等”并单击“发布”时。然后我将设置输入为“发布方法:文件系统”。我将目标位置设置为“C:\www\sigex.com”。我在“c:\windows\system32\drivers\etc\hosts”文件中使用了“127.0.0.1 sigex.com”来在本地使用这个域(效果很好)。
发布设置如下图所示;
设置发布配置后,我收到以下警告框;
tmp文件里面有以下内容;
03/06/2018 17:10:54
System.AggregateException: One or more errors occurred. ---> System.Exception: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass41_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__116.MoveNext()
---> (Inner Exception #0) System.Exception: Build failed. Check the Output window for more details.<---
===================
在“网络发布活动”中,我得到以下信息;
任何人都可以帮助我解决我哪里出错了吗?我在这里找到了这篇文章,上面说他们遇到了同样的问题。
https://github.com/dotnet/core/issues/1039
但是他们说这只会发生在
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
在 *.csproj 中设置。我的 *.csproj 中没有上述内容
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>aspnet-Onion.Website-23EA0CB5-7C55-42E5-80E3-8CD26CCDBA6C</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-preview1-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0-preview1-final" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0-preview1-final" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<!-- obsolete references -->
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0-preview1-final" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0-preview1-final" />
<!--<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" />-->
<!--<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.2" />-->
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Onion.Repositories\Onion.Repositories.csproj" />
<ProjectReference Include="..\Onion.Services\Onion.Services.csproj" />
</ItemGroup>
</Project>
我尝试选择 x86 作为 cpu 目标,但这并没有什么不同。请帮忙。
【问题讨论】:
-
您可以尝试使用 dotnet cli 发布。
dotnet publish -c Release -r win7_x64 --self-contained。用你的目标运行时替换 win7_x64 -
我使用了 dotnet publish -c Release -r win10-x64 --self-contained 成功了。我有点不确定我应该在这里复制什么。所以我将“win10-x64”文件夹内容复制到“c:\www\sigex.com”中。我现在在尝试访问 sigex.com 本地 dns 规则时看到以下错误 HTTP 错误 401.3 - 未经授权 由于此资源的访问控制列表 (ACL) 配置或加密设置,您无权查看此目录或页面网络服务器。 stackoverflow.com/questions/8232922/…
-
尝试将 sigex.com 文件夹的完全访问权限授予
IIS_IUSRS和IUSR。同时取消选中该文件夹上的只读标志 -
始终编辑您的问题以包含新信息(而不是将它们留在 cmets 中)。如果您确实使用
dotnet publish,我相信如果您还没有在项目中放置自定义的web.config,将会生成。 500.19错误可以说是人尽皆知,大家只需要在IIS上安装ASP.NET Core模块即可修复。 -
.NET Core 和 .NET Framework 是两个不同的平台,具有不同的 CLR 实现(尽管大多数代码相似或共享)。您可以参考 CLR 上其他著名的 SO 问题。