Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jonsagara opened this issue Jul 1, 2016 · 8 comments

Comments

@jonsagara
Copy link

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)

  7. In Visual Studio, right-click on src, and add a new Class Libary (.NET Core) project.

  8. In the original Web App project, right-click on References and add a project reference to the class library added in Step 7.

  9. Commit changes to git, and then push to GitHub.

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

@davidebbo
Copy link
Member

davidebbo commented Jul 1, 2016

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": {}
  },

@davidebbo
Copy link
Member

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!

@jonsagara
Copy link
Author

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"

@davidebbo
Copy link
Member

davidebbo commented Jul 1, 2016

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

@vijayrkn
Copy link

vijayrkn commented Jul 1, 2016

@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;

@davidebbo
Copy link
Member

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

Closing this one for now since @jonsagara is unblocked.

@casperOne
Copy link

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)?

@vijayrkn
Copy link

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.
#2111
(There was an earlier bug but it was created in the wrong repo.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants