Publish ASP.Net Core 2.1preview2 website to local IIS MSB3030 *.PrecompiledViews.dll

Deadly 提交于 2020-01-01 12:12:11

问题


Update 1

With @Priyesh Kumar feedback I have used the following command from the websites root folder (the one with *.csproj for the website). This worked. I then copied the "win10-x64" content files into c:\www\sigex.com.

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

I am running into a few different issues now but will fix them and then post back the solution.

Original Post

Hi I am trying to publish my website locally into IIS (a site I have made in IIS manager). I am using the right click publish option in visual studio.

In IIS Manager my settings are;

For the application pool I have the following

When I click "Publish" and select "IIS, FTP, etc" and click "Publish". I then enter the settings as "Publish method: File System". I set the target location to "C:\www\sigex.com". I have used "127.0.0.1 sigex.com" in the "c:\windows\system32\drivers\etc\hosts" file to use this domain locally (that works fine).

The publish settings are shown below;

After the publish configuration is set I get the following alert box;

The tmp file has the following content inside it;

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

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

Inside the "Web Publish Activity" I get the following;

https://pastebin.com/QRsvhTHU

Can any body help me on where I am going wrong? I found this post here which says they are getting the same issue.

https://github.com/dotnet/core/issues/1039

However they said this is only occuring when

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>

is set in the *.csproj. I do not have the above in my *.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>

I tried selecting x86 as the cpu target but that made no difference. Please help.


回答1:


Try publishing using dotnet cli command

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

-c: Publish configuration, Release|Debug

-r: Targeted runtime environment. Full list here

--self-contained: Downloads and created a self contained package which can be run without dotnet sdk.

  1. Copy folder in bin/Release/netcoreapp2.1/win10-x64/publish, where web.config is present to your deployment location.
  2. Make sure to install Dotnet core hosting bundle for IIS.
  3. Restart the IIS
  4. Create a new pool with .NET CLR version as No Managed Code
  5. Give read/write permission to IIS_IUSRS and IUSR.
  6. Create new website with above app pool and code location.

Read official docs.

You might be interested in CORS also. Install IIS cors from here.

Note: All version are specific to OP's system. Make sure to replace the versions. Note: Make sure you have updated Visual studio to support dotnet core



来源:https://stackoverflow.com/questions/50668728/publish-asp-net-core-2-1preview2-website-to-local-iis-msb3030-precompiledviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!