4

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;

enter image description here

For the application pool I have the following

enter image description here

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;

enter image description here enter image description here

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

enter image description here

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.

Sigex
  • 2,834
  • 2
  • 24
  • 25
  • can you try publishing using dotnet cli. `dotnet publish -c Release -r win7_x64 --self-contained`. replace win7_x64 with your target runtime – Priyesh Kumar Jun 03 '18 at 16:58
  • I used dotnet publish -c Release -r win10-x64 --self-contained It worked. I am a little unsure what I am supposed to copy here. So I copied the "win10-x64" folders content into "c:\www\sigex.com". I now see the following error when attempting to go to sigex.com local dns rule HTTP Error 401.3 - Unauthorized You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server. https://stackoverflow.com/questions/8232922/asp-pages-in-iis-using-localhost-401-3-error-do-not-have-permission – Sigex Jun 03 '18 at 17:17
  • try giving full access on sigex.com folder to `IIS_IUSRS` and `IUSR`. Also uncheck readonly flag on that folder – Priyesh Kumar Jun 03 '18 at 17:20
  • Okay so giving access to IIS_IUSRS did not resolve the issue. I went into IIS Manager -> Desktop -> Authentication -> ASP.Net Impersonation : Enabled. Now I get another error message about web.config. This is an ASP.Net Core 2.1 application and it does not have a web.config whilst in development. I have read that it is supposed to be generated when publishing but I do not see it. HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. – Sigex Jun 03 '18 at 17:22
  • .NET Core 2.1 final is out. You need to upgrade to that supported version first. Besides, please consider publishing via `dotnet publish` command line. – Lex Li Jun 03 '18 at 17:23
  • yes, from your screenshot I see that .NET CLR version is v4.0, which means IIS will interpret the site as .NET framework code. Create new app pool and make sure to select .NET CLR version to `No Managed Code` from the drop down – Priyesh Kumar Jun 03 '18 at 17:25
  • @LexLi I will update to .Net Core 2.1 final soon. I will check back if that fixes the issue but I suspect it should not matter. If I don't check back then it didn't resolve the issue. PS I used dotnet publish (see above) and it worked successfully. – Sigex Jun 03 '18 at 17:29
  • @PriyeshKumar I thought .Net CLR is common language runtime and that .Net Core and .Net Framework run on the same CLR? – Sigex Jun 03 '18 at 17:30
  • 1
    Always edit your question to include new information (instead of leaving them in comments). If you do use `dotnet publish` I believe `web.config` would be generated if you don't put a custom one in your project yet. The 500.19 error can be so well known that everyone just needs to install ASP.NET Core module on IIS to fix it. – Lex Li Jun 03 '18 at 17:31
  • 1
    .NET Core and .NET Framework are two different platforms, with different CLR implementation (though most code is similar or shared). You might refer to other famous SO questions on CLR. – Lex Li Jun 03 '18 at 17:32
  • Hi all I'm making some progress now. I will check back in soon. When I have a solid solution I will update the OP. But I will update to include the dotnet publish command. – Sigex Jun 03 '18 at 17:40

1 Answers1

6

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

Priyesh Kumar
  • 2,837
  • 1
  • 15
  • 29
  • https://learn.microsoft.com/en-us/dotnet/core/rid-catalog the run time identifier for windows 10 is win10-x64 not win10_x64. – Sigex Jun 03 '18 at 18:11
  • Hi @Priyesh Kumar, I am running into another issue now. (The Web server is configured to not list the contents of this directory.) A default document is not configured for the requested URL, and directory browsing is not enabled on the server. I am not interested in directory browsing so this is an issue of it not knowing what the default file is. Web.config was generated – Sigex Jun 03 '18 at 18:17
  • Not sure if this is what you are looking for. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.0&tabs=aspnetcore2x#serve-a-default-document – Priyesh Kumar Jun 03 '18 at 18:21
  • Hi @Priyesh Kumar. Nope adding this change it does not fix the issue. I am currently still working on resolving it. I am watching the Microsoft build video and it is helping (but is for .Net Core 1.0) https://www.youtube.com/watch?v=7TERFQ_U9W0 – Sigex Jun 03 '18 at 21:47
  • 1
    The note about the CORS saved me actually. It may be worth to mention in bold or critical point here as well. – Ak777 May 18 '20 at 06:04