关于c#:ASP.NET核心IISIntegration.Tools和.NET Framework

ASP.NET Core IISIntegration.Tools and .NET Framework

在ASP.NET核心1.0中,我使用了:

0

要运行dotnet publish命令,但在ASP.NET核心1.1中,我开始出现以下错误:

Package Microsoft.AspNetCore.Server.IISIntegration.Tools
1.1.0-preview4-final is not compatible with net462 (.NETFramework,Version=v4.6.2). Package
Microsoft.AspNetCore.Server.IISIntegration.Tools 1.1.0-preview4-final
supports: netcoreapp1.0 (.NETCoreApp,Version=v1.0)

如何在ASP.NET核心和常规.NET框架中仍然使用"dotnet publish-iis"?

JSON:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
 "dependencies": {
   "Dapper":"1.50.2",
   "log4net":"2.0.5",
   "Microsoft.AspNetCore.Authorization":"1.1.0",
   "Microsoft.AspNetCore.Diagnostics":"1.1.0",
   "Microsoft.AspNetCore.Routing":"1.1.0",
   "Microsoft.AspNetCore.Server.IISIntegration":"1.1.0",
   "Microsoft.AspNetCore.Server.IISIntegration.Tools":"1.1.0-preview4-final",
   "Microsoft.AspNetCore.Server.Kestrel":"1.1.0",
   "Microsoft.AspNetCore.StaticFiles":"1.1.0",
   "Microsoft.Extensions.Caching.Abstractions":"1.1.0",
   "Microsoft.Extensions.Caching.Memory":"1.1.0",
   "Microsoft.Extensions.Configuration.FileExtensions":"1.1.0",
   "Microsoft.Extensions.Configuration.Json":"1.1.0",
   "Microsoft.Extensions.Logging.Console":"1.1.0",
   "Microsoft.Extensions.Logging.Debug":"1.1.0",
   "Microsoft.Extensions.Options.ConfigurationExtensions":"1.1.0"
  },
 "tools": {
   "Microsoft.AspNetCore.Server.IISIntegration.Tools":"1.1.0-preview4-final"
  },
 "frameworks": {
   "net462": {}
  },
 "buildOptions": {
   "emitEntryPoint": true,
   "preserveCompilationContext": true
  },
 "publishOptions": {
   "include": [
     "wwwroot",
     "web.config",
     "appsettings.json",
     "log4net.xml",
    ]
  },
 "scripts": {
   "prepublish": [ ],
   "postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },
 "configurations": {
   "Debug": {
     "buildOptions": {
       "define": [
         "DEBUG",
         "TRACE"
        ]
      }
    },
   "Integration": {
     "buildOptions": {
       "define": [
         "DEBUG",
         "TRACE"
        ]
      }
    },
   "Production": {
     "buildOptions": {
       "define": ["RELEASE","TRACE" ],
       "optimize": true
      }
    }
  }
}


1)将所有包更新到1.1.0版(以及相应的工具预览)

2)工具包应安装在project.jsontools段,而不是dependencies段。

因此,请确保您在project.json的工具部分下添加了IISIntegration.Tools,如下所示-

1
2
3
4
"tools": {
    ....
     "Microsoft.AspNetCore.Server.IISIntegration.Tools":"1.1.0-preview4-final",
    ....

3)取下旧的project.lock.json,重新运行dotnet restore

4)现在可以使用-dotnet publish发布了。

看看这是否有帮助。