简体   繁体   中英

ASP.Net Core Web Application (.Net Framework) created with VS2015 creates a dodgy looking project

I'm creating an application using ASP.Net Core, it's just a prototype atm to test various technologies. I need it to use Dotnet Framework instead of Dotnet Core. (One of the reasons being that I need Dotnet Framework's support for COM interop).

I have VS2015 Update 3 running on Win7 x64.

I select File -> New -> Project, then in the New Project dialog, I select .Net Framework 4.6 in the Dotnet version dropdown and Web -> 'ASP.Net Core Web Application (.Net Framework)' from the project tree to create a new Web Application.

It builds and runs but I don't fully understand the configuration of the project that has been created.

The project uses a project.json file instead of packages.config. This I think I understand and is because ASP.Net Core requires use of Nuget 3 instead of Nuget 2.

What I don't understand is that when I build the project in my output directory I have a subdirectory ./net46/win7-x64 and in there is some strange stuff indeed.

libuv.dll and a load of Microsoft.AspNetCore.<whatever> makes sense, Asp.Net isn't part of the Dotnet Framework so nuget resolves that dependency and copies it to my output directory. However I also have a load of nuget. assemblies in my output directory. What is that doing there? My application doesn't use nuget internally so why should that need to be shipped as a dependency?

Equally confusing are a load of System.<whatever> assemblies, like for example System.Threading.Thread.dll v1.0.24212.1. Now the Dotnet Framework doesn't have a System.Threading.Thread.dll, it has a System.Threading.dll v4.6.1085.0.

These System.<whatever> dlls are actually Dotnet Core libraries (they match assemblies in c:\\Program Filess\\dotnet\\shared), but this project was created using the project wizard that is supposed to use Dotnet Framework, not Dotnet Core, so what are all these Dotnet Core assemblies doing in my output directory?

I suspect the issue is related to deployment modes. Dotnet Core has two deployment modes. Framework dependent and self-contained. Framework dependent means the application doesn't ship it's own Dotnet Core assemblies, it replies on Dotnet Core already being installed on the target machine and uses that. Self-contained means the application ships all it's own Dotnet Core dependencies.

This raises two questions though. Framework dependent and self-contained are Dotnet Core deployment modes, 1) there is nothing in the documentation to suggest that they have anything to do with an application that uses Dotnet Framework instead, and 2) the documentation states that Framework Dependent is the default, but it doesn't seem to be and I haven't changed anything.

https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/index

To create an ASP.Net Core app using Dotnet Framework I would have expected to have an application that just referenced a few extra Microsoft.AspNetCore. libraries copied to its output, but what I actually have is something quite different and I don't know why.

Can anyone shed some light on this please?

UPDATE: Added project.json for reference.

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net46": { }
  },

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

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

The assemblies that in Output path based on the platform that will run your application.

For your situation, you are creating a ASP.NET Core Web Application (.NET Framework), which is a .NET Framework application and it needs .NET Framework installed on Windows machine to run this application.

And this type of project needs .NET Core assemblies and these .NET Core related assemblies are referenced as packages. And these assemblies stored in Win7-x64 folder, which means these assemblies will be called by .NET Framework in Win7 x64 machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM