9

I just converted a working RC2 web application to RTM and I have some issues publishing on IIS.

All the samples I have found are based on a NetCoreApp1.0 application. Due to some requirements, we are restricted to "net46".

Here is the project.json

{
  "version": "1.0.0-*",
  "dependencies": {
    "Domain": "1.0.0-*",
    "Microsoft.AspNetCore.Authentication": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0",
    "Microsoft.AspNetCore.DataProtection.SystemWeb": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Http.Extensions": "1.0.0",
    "Microsoft.AspNetCore.Localization": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "PublicLib": "1.0.0-*",
    "PublicLib.Imaging": "1.0.0-*",
    "PublicLib.Interfaces": "1.0.0-*",
    "Storage": "1.0.0-*"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final"
    }
  },

  "frameworks": {
    "net46": {

    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config",
      "Views",
      "appsettings.json",
      "database.json",
      "PublicWeb.nuspec"
    ]
  },

  "packOptions": {

  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

This is the error I get

Errors in C:\Development\Path\To\Web\Application\project.json
    Package Microsoft.DotNet.ProjectModel 1.0.0-rc3-003121 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.DotNet.ProjectModel 1.0.0-rc3-003121 supports:
      - net451 (.NETFramework,Version=v4.5.1)
      - netstandard1.6 (.NETStandard,Version=v1.6)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.

If I change the "tools" sections as follows,

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "net451"
    }
  },

I manage to restore the solution, but when I try to publish the solution with dotnet publish .\Path\To\Web\Application\ -o .\tmp\public\, I get the following output

Publishing PublicWeb for .NETFramework,Version=v4.6/win7-x64
Project Domain (.NETFramework,Version=v4.6) was previously compiled. Skipping compilation.
Project PublicLib.Interfaces (.NETFramework,Version=v4.6) was previously compiled. Skipping compilation.
Project PublicLib (.NETFramework,Version=v4.6) was previously compiled. Skipping compilation.
Project PublicLib.Imaging (.NETFramework,Version=v4.6) was previously compiled. Skipping compilation.
Project Storage (.NETFramework,Version=v4.6) was previously compiled. Skipping compilation.
Project PublicWeb (.NETFramework,Version=v4.6) will be compiled because inputs were modified
Compiling PublicWeb for .NETFramework,Version=v4.6

Compilation succeeded.
    0 Warning(s)
    0 Error(s)

Time elapsed 00:00:01.8045183


Configuring the following project for use with IIS: '.\tmp\public\'
Could not load file or assembly 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Microsoft.AspNetCore.Server.IISIntegration.Tools.PublishIISCommand.Run()
   at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.<>c__DisplayClass0_0.<Main>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.AspNetCore.Server.IISIntegration.Tools.Program.Main(String[] args)
publish: Published to .\tmp\public\
Published 1/1 projects successfully

Event if it says Published 1/1 projects successfully, the .\tmp\public\web.config contains the following line.

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>

Whilst it used to contain

<aspNetCore processPath=".\PublicWeb.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />

The second one is a working configuration for IIS on a deployed server.

Any suggestion on how to fix this?

Thanks

Kralizek
  • 1,999
  • 1
  • 28
  • 47
  • When you sue `dotnet --version` what do you see? I've seen this behavior quite a few time after the preview 2 release where preview 1 tooling was still winning in the path and it doesn't know that `netcoreapp1.0` refs `netstandard1.6` (only `netstandard1.5`, which many packages no longer include). – Nick Craver Jun 29 '16 at 20:33
  • at the moment of the post, I was getting `preview1`. I fixed the global.json by removing the sdk:version key and now I get `preview2` of dotnet cli. Still no luck with the reference. – Kralizek Jun 29 '16 at 20:38

5 Answers5

7

here is what helped me.

enter dotnet --version in the CMD, if it shows that you use version preview1 then here is what you will need to do in order to clean up the cache and enforce using preview2.

first make sure preview2 is in your computer, on windows it should be under C:\Program Files\dotnet\sdk if you have 1.0.0-preview2-003121 in the dir, then you are good to go, otherwise download the latest sdk first, and make sure you have the latest .Net core installed as well, and delete the dnx folder from your system since its not relevant anymore (changed to dotnet).

delete the preview1 sdk version from the dotnet sdk dir.

in your project folder edit your global.json file should be like this.

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}

now restart your pc to make sure all services and processes is being restarted, run dotnet restore and now it works, it will first run some updates on the cache, but dont worry takes about a minute or 2 depends on your OS specs, then it will execute the restore.

Sol Stein
  • 656
  • 10
  • 29
  • global.json is often located in the solution folder and the sdk version refers to the path: %ProgramFiles%\dotnet\sdk\ – Ole K Oct 14 '16 at 12:53
3

I'm having an identical problem and was able to publish again by rolling back IISIntegration.Tools to 1.0.0-preview1-final

"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
  "version": "1.0.0-preview1-final",
  "imports": "portable-net45+win8+dnxcore50"
}
UrbanDude
  • 436
  • 2
  • 5
  • Having the same issue and that didn't work in my case. – Benzara Tahar Jun 29 '16 at 09:13
  • I'll mark this as accepted answer as it fixed the issue in my case. I am aware it's a workaround. – Kralizek Jun 29 '16 at 14:55
  • You should have this instead: "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-preview2-final" } – davidfowl Jun 29 '16 at 15:11
  • Using "1.0.0-preview2-final" is what appears to be triggering the publishing error `System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.` – UrbanDude Jun 29 '16 at 19:33
  • Acting on the assumption that because I'm not even targeting Windows and IIS, I was able to fix this problem simply by removing the entire Microsoft.AspNetCore.Server.IISIntegration.Tools subsection. – robbpriestley Jun 30 '16 at 17:00
1

I was able to fix this by installing the .NET Core SDK from the dot.net website, check this a discussion about this here for more details.

Benzara Tahar
  • 2,058
  • 1
  • 17
  • 21
0

It was NuGet related for me.

Before I fixed it, I had been getting the error:

Could not load file or assembly 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

I discovered that I had a Visual Studio version of NuGet and a command line version of NuGet on my machine. I removed the command line version, which was older.

I found the command line version by dropping into the command line and running NuGet which displayed version 2.8. Running the Visual Studio extension manager, the version it was reported was 3.5.

I uninstalled the command line NuGet version.

I also cleared the NuGet cache:

nuget locals -all clear

I'm not entirely sure if it was having the two, different version or if it was clearing the cache, but after doing both, I'm no longer getting the ProjectModel error.

Community
  • 1
  • 1
Brad Rem
  • 6,036
  • 2
  • 25
  • 50
0

Download NuGet.exe from here https://dist.nuget.org/index.html

Open Command prompt and go to the directory and execute following command for example: C:/Users/Username/Downloads> nuget.exe locals -Clear all

This resolved my issue System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.ProjectModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Muheeb
  • 216
  • 2
  • 6