Kudu: Unable to deploy ASP.NET Core 1.0 app to Azure when it references a .NET Core class library

Created on 1 Jul 2016  路  8Comments  路  Source: projectkudu/kudu

Problem: I'm unable to deploy an ASP.NET Core 1.0 app to Azure App Service when there are referenced .NET Core 1.0 class libraries.

Repro steps:

  1. Create a ASP.NET Core 1.0 Web App in Visual Studio 2015 w/ Update 3 and RTM tooling.
  2. Commit to git (see commit 7b187403) and push to GitHub.
  3. Set up a new Azure App Service for the web app (http://aspnetcoreazuretest.azurewebsites.net)
  4. Set the Deployment Source as git
  5. Monitor the deployment, and see that it eventually succeeds.
  6. Visit the website and see the default ASP.NET Core 1.0 website as generated by Visual Studio. Success!

(But this is where it fails)

  1. In Visual Studio, right-click on src, and add a new Class Libary (.NET Core) project.
  2. In the original Web App project, right-click on References and add a project reference to the class library added in Step 7.
  3. Commit changes to git, and then push to GitHub.
  4. Get the following error when Azure tries to deploy the latest changes:
```
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment with MSBuild.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring packages for D:\home\site\repository\src\AspNetCoreAzureTest.Common\project.json...
Restoring packages for D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Committing restore...
Lock file has not changed. Skipping lock file write. Path: D:\home\site\repository\src\AspNetCoreAzureTest.Common\project.lock.json
D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj
Restore completed in 2068ms.
Restoring packages for tool 'BundlerMinifier.Core' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Committing restore...
Lock file has not changed. Skipping lock file write. Path: D:\home\site\repository\src\AspNetCoreAzureTest\project.lock.json
D:\home\site\repository\src\AspNetCoreAzureTest\AspNetCoreAzureTest.xproj
Restore completed in 16329ms.

NuGet Config files used:
    C:\DWASFiles\Sites\#1AspNetCoreAzureTest\AppData\NuGet\NuGet.Config

Feeds used:
    https://api.nuget.org/v3/index.json
  D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\src\AspNetCoreAzureTest.Common" --configuration Release --no-dependencies
  Project AspNetCoreAzureTest.Common (.NETStandard,Version=v1.6) will be compiled because expected outputs are missing
  Compiling AspNetCoreAzureTest.Common for .NETStandard,Version=v1.6
  Compilation succeeded.
      0 Warning(s)
      0 Error(s)
  Time elapsed 00:00:02.7327835

  Environment variables:
  Path=C:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\NativeBinaries/x86;D:\home\site\deployments\tools;C:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\Scripts;D:\Program Files (x86)\MSBuild\14.0\Bin;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;D:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn;D:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0;D:\Program Files (x86)\Git\bin;D:\Program Files (x86)\Git\usr\bin;D:\Program Files (x86)\npm\3.5.1;C:\DWASFiles\Sites\#1AspNetCoreAzureTest\AppData\npm;D:\Program Files (x86)\bower\1.3.12;D:\Program Files (x86)\grunt\0.1.13;D:\Program Files (x86)\gulp\3.9.0.1;D:\Program Files (x86)\nodejs\4.2.3;D:\Windows\system32;D:\Windows;D:\Windows\System32\Wbem;D:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\Microsoft Network Monitor 3\;D:\Users\Administrator\AppData\Roaming\npm;D:\Program Files (x86)\nodejs\;d:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\Mercurial\;E:\base\x64;E:\base\x86;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x64;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x86;D:\Program Files (x86)\dotnet;D:\Python27;
  D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\src\AspNetCoreAzureTest.Common" --output "D:\local\Temp\PublishTemp\AspNetCoreAzureTest.Common87" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 1. The project has not been restored or restore failed - run `dotnet restore` [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 2. The project does not list one of 'win8-x86, win7-x86' in the 'runtimes' section. [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries. [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\AspNetCoreAzureTest.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="D:\local\Temp\8d3a1f63be58337"
An error has occurred during web site deployment.
\r\nC:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
```

Any ideas?

I have a repo that demonstrates the failure:

https://github.com/jonsagara/AspNetCoreAzureTest

Most helpful comment

@davidebbo We have a tfs bug tracking the work required to
1) Publish only the web projects in the solution when deployOnBuild is set as true.
2) Add an option to pass the projects to deploy to solution build /p:deployProjects=Projecta;Projectb;

All 8 comments

Fix is to add a "runtimes" section to the project.json of the library project. See https://github.com/jonsagara/AspNetCoreAzureTest/pull/2. Looks like:

  "runtimes": {
    "win7-x86": {}
  },

In some earlier email, @vijayrkn wrote:

The default publish experience for a class library seems to be broken if a runtime is not specified. (dotnet.exe publish on a class library created from template fails.)

Vijay can you confirm that this issue is tracked somewhere on your side? Thanks!

I still get a failure with the fix:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment with MSBuild.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring packages for D:\home\site\repository\src\AspNetCoreAzureTest.Common\project.json...
Restoring packages for D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Committing restore...
Lock file has not changed. Skipping lock file write. Path: D:\home\site\repository\src\AspNetCoreAzureTest.Common\project.lock.json
D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj
Restore completed in 2289ms.
Restoring packages for tool 'BundlerMinifier.Core' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\home\site\repository\src\AspNetCoreAzureTest\project.json...
Committing restore...
Writing lock file to disk. Path: D:\home\site\repository\src\AspNetCoreAzureTest\project.lock.json
D:\home\site\repository\src\AspNetCoreAzureTest\AspNetCoreAzureTest.xproj
Restore completed in 20114ms.

NuGet Config files used:
    C:\DWASFiles\Sites\#1AspNetCoreAzureTest\AppData\NuGet\NuGet.Config

Feeds used:
    https://api.nuget.org/v3/index.json
  D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\src\AspNetCoreAzureTest.Common" --configuration Release --no-dependencies
  Project AspNetCoreAzureTest.Common (.NETStandard,Version=v1.6) was previously compiled. Skipping compilation.
  Environment variables:
  Path=C:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\NativeBinaries/x86;D:\home\site\deployments\tools;C:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\Scripts;D:\Program Files (x86)\MSBuild\14.0\Bin;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;D:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn;D:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0;D:\Program Files (x86)\Git\bin;D:\Program Files (x86)\Git\usr\bin;D:\Program Files (x86)\npm\3.5.1;C:\DWASFiles\Sites\#1AspNetCoreAzureTest\AppData\npm;D:\Program Files (x86)\bower\1.3.12;D:\Program Files (x86)\grunt\0.1.13;D:\Program Files (x86)\gulp\3.9.0.1;D:\Program Files (x86)\nodejs\4.2.3;D:\Windows\system32;D:\Windows;D:\Windows\System32\Wbem;D:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\Microsoft Network Monitor 3\;D:\Users\Administrator\AppData\Roaming\npm;D:\Program Files (x86)\nodejs\;d:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\Mercurial\;E:\base\x64;E:\base\x86;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x64;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x86;D:\Program Files (x86)\dotnet;D:\Python27;
  D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\src\AspNetCoreAzureTest.Common" --output "D:\local\Temp\PublishTemp\AspNetCoreAzureTest.Common87" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 1. The project has not been restored or restore failed - run `dotnet restore` [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 2. The project does not list one of 'win8-x86, win7-x86' in the 'runtimes' section. [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries. [D:\home\site\repository\src\AspNetCoreAzureTest.Common\AspNetCoreAzureTest.Common.xproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\AspNetCoreAzureTest.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="D:\local\Temp\8d3a1fa837d0932"
An error has occurred during web site deployment.
\r\nC:\Program Files (x86)\SiteExtensions\Kudu\56.50630.2306\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

My bad, it needs to be added to the project.json of the _library_! I tested it and that works :)

Here it is in my own test project: https://github.com/davidebbo-test/AspNetCoreVS/blob/92e01630e7ef5b8549dc9a635dea276bb0395bec/src/MyCoreLib/project.json#L4-L6

@davidebbo We have a tfs bug tracking the work required to
1) Publish only the web projects in the solution when deployOnBuild is set as true.
2) Add an option to pass the projects to deploy to solution build /p:deployProjects=Projecta;Projectb;

Awesome, thanks. Please let me and @ahmelsayed know when it's available.

Closing this one for now since @jonsagara is unblocked.

Will the fix involve not needing the runtimes section anymore?

I ask because if our class libraries are targeting .NET Standard, isn't that supposed to remove the need to have knowledge of specific framework instances (and by extension, runtimes)?

This was the original bug created for dotnet cli to fix the default publishing behavior for class lib but this was closed (by design) because class libraries are only supposed to be packed and not published - https://github.com/dotnet/cli/issues/3764#issuecomment-235807800

I have created a bug in the kudu repo to update the script so that while publishing the project in the solution, only the web project in the solution is published and the class lib/console apps in the solution is omitted.
https://github.com/projectkudu/kudu/issues/2111
(There was an earlier bug but it was created in the wrong repo.)

Was this page helpful?
0 / 5 - 0 ratings