aspnet / IISIntegration

[Archived] ASP.NET Core IIS integration. Project has moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
149 stars 59 forks source link

Publish to IIS issue after upgrade to 2.0 #409

Closed tom-cognify closed 6 years ago

tom-cognify commented 7 years ago

I upgraded a ASP.NET CORE 1.1 app that targets the full framework 4.6.2. Everything works fine in development running under IIS Express on win10. When I publish to our Windows 2012 R2 servers, the app fails to start and I'm getting this error in the sdout logs.

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at CaseLogic.Web.Program.BuildWebHost(String[] args) at CaseLogic.Web.Program.Main(String[] args)

I did install the .NET Core Windows Server Hosting bundle for 2.0 and I went through the troubleshooting guide for IIS deployment on the docs site, but not seeing any guidance on this error.

Thanks

Tratcher commented 7 years ago

Can you run the published app from the command line on that server?

tom-cognify commented 7 years ago

no, I get the same error if I try to run at the command line

Tratcher commented 7 years ago

What does your csproj look like?

tomerisr commented 7 years ago

Hi, Make sure you have all config files in the directory. I was having the same issue with the deployment of a windows service.

techaimail commented 7 years ago

I have the same error and configuration:

Windows 2012 R2 with iis and Microsoft .NET Core 2.0.0 - Windows Server Hosting (and .net core runtime 2.0.0), running a web app using c# over .NET 4.6.2 compiled using visual studio 2017 enterprise all with lastest updates.

image

That error does not happen using the same configuration in windows 10.

Thanks in advance for your help

tomerisr commented 7 years ago

Removing codegen reference from csproj also solves a similar issue.

techaimail commented 7 years ago

When I remove these lines all work fine for web projects .net for mvc6 (but the same lines work fine with other web projects with .net core for mvc6)

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Xdt.Tools" Version="2.0.0" />
</ItemGroup>

<Target Name="RemoveHandlersFromWebConfig" AfterTargets="_TransformWebConfig">
        <PropertyGroup>
            <_SourceWebConfig>$(PublishDir)App.config</_SourceWebConfig>
            <_XdtTransform>$(MSBuildThisFileDirectory)App.$(ConfigurationName).config</_XdtTransform>
            <_TargetWebConfig>$(PublishDir)$(TargetFileName).config</_TargetWebConfig>
        </PropertyGroup>
        <Exec Command="dotnet transform-xdt --xml &quot;$(_SourceWebConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetWebConfig)&quot;" />
        <Exec Command="del $(PublishDir)App*.config" />
    </Target>
<_XdtTransform>$(MSBuildThisFileDirectory)App.$(ConfigurationName).config</_XdtTransform>
            <_TargetWebConfig>$(PublishDir)$(TargetFileName).config</_TargetWebConfig>
        </PropertyGroup>
        <Exec Command="dotnet transform-xdt --xml &quot;$(_SourceWebConfig)&quot; --transform &quot;$(_XdtTransform)&quot; --output &quot;$(_TargetWebConfig)&quot;" />
        <Exec Command="del $(PublishDir)App*.config" />
    </Target>
muratg commented 6 years ago

We're closing this issue as no response or updates have been provided in a timely manner and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.