将ASP.Net Core 2.1preview2网站发布到本地IIS MSB3030 * .PrecompiledViews.dll

问题描述 投票:4回答:1

更新1

有了@Priyesh Kumar的反馈,我使用了网站根文件夹中的以下命令(该网站带有* .csproj的文件夹)。这很有效。然后我将“win10-x64”内容文件复制到c:\ www \ sigex.com。

 dotnet publish -c Release -r win10-x64 --self-contained

我现在遇到了一些不同的问题,但会修复它们,然后回复解决方案。

原帖

嗨,我正在尝试将我的网站本地发布到IIS(我在IIS管理器中创建的网站)。我在visual studio中使用右键单击发布选项。

在IIS管理器中,我的设置是;

enter image description here

对于应用程序池,我有以下内容

enter image description here

当我单击“发布”并选择“IIS,FTP等”并单击“发布”。然后我将设置输入为“发布方法:文件系统”。我将目标位置设置为“C:\ www \ sigex.com”。我在“c:\ windows \ system32 \ drivers \ etc \ hosts”文件中使用“127.0.0.1 sigex.com”在本地使用此域(工作正常)。

发布设置如下所示;

enter image description here enter image description here

设置发布配置后,我得到以下警告框;

enter image description here

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.<---

===================

在“Web发布活动”中,我得到以下内容;

https://pastebin.com/QRsvhTHU

任何身体可以帮助我在哪里出错吗?我在这里发现这篇帖子说他们遇到了同样的问题。

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目标,但没有区别。请帮忙。

asp.net-core-2.0 iis-10
1个回答
5
投票

尝试使用dotnet cli命令发布

  1. dotnet publish -c Release -r win10-x64 --self-contained

-c:发布配置,发布|调试

-r:有针对性的运行时环境。完整列表here

- 自包含:下载并创建一个自包含的包,可以在没有dotnet sdk的情况下运行。

  1. bin/Release/netcoreapp2.1/win10-x64/publish中复制文件夹,其中web.config存在于您的部署位置。
  2. 确保为IIS安装Dotnet核心hosting bundle
  3. 重新启动IIS
  4. 使用.NET CLR版本创建一个新池作为No Managed Code
  5. IIS_IUSRSIUSR授予读/写权限。
  6. 使用上面的应用池和代码位置创建新网站。

阅读官方docs

您可能也对CORS感兴趣。从here安装IIS cors。

注意:所有版本都特定于OP的系统。确保更换版本。注意:确保您已更新Visual Studio以支持dotnet核心

© www.soinside.com 2019 - 2024. All rights reserved.