鍗囩骇鏂囨。锛�/p>
ASP.NET Core 1.0 RC2 鍙戝竷锛�a href="http://www.cnblogs.com/xishuai/p/dotnet-core-rc2-and-dotnet-core-sdk-preview1.html">瑙h鍙戝竷锛�NET Core RC2 and .NET Core SDK Preview 1
涔嬪墠锛屼娇鐢�ASP.NET 5 RC1 寮�彂浜嗕竴涓」鐩紝骞朵笖杩欎釜椤圭洰宸茬粡鐢ㄤ簬鐢熶骇鐜锛岄」鐩腑鍖呭惈鐨勪竴浜涗笢瑗匡細
鐜板湪瑕佸崌绾у埌 ASP.NET Core 1.0 RC2锛屽畼鏂瑰崌绾ф枃妗e彧鏄畝鍗曠殑浠嬬粛浜嗕笅锛屽疄闄呭崌绾х殑杩囩▼涓繕鏄亣鍒颁簡涓嶅皯鐨勯棶棰橈紝鎴戜滑骞冲父寮�彂 ASP.NET 搴旂敤绋嬪簭锛屼笂闈㈡墍鍒楀嚭鐨勪笢瑗垮熀鏈兘鍖呭惈浜嗭紝鎵�互锛屼笅闈㈢邯褰曞崌绾х殑杩囩▼锛屽寘鍚竴浜涢棶棰樺拰瑙e喅鏂瑰紡锛屽笇鏈涘彲浠ュ府鍔╁埌澶у銆�/p>
鍗囩骇鐨勯瑕佸墠鎻愶紝寮�彂鐜闇�瀹夎锛�/p>
鐒跺悗锛屾垜浠墦寮�ASP.NET 5 RC1 搴旂敤绋嬪簭鐨勮В鍐虫柟妗堬細
鏄犲叆鐪煎笜鐨勬槸绋嬪簭鍖呰繕鍘熷け璐ワ紝骞朵笖鏄竴澶у爢閿欒锛�/p>
浠�箞楝硷紵鏈夌偣鑾悕鍏跺锛岀▼搴忓寘杩樺師澶辫触鐨勫師鍥犳槸锛屽湪鍘熸湁鐨勭▼搴忓寘婧愪腑鎵句笉鍒颁簡锛屽叿浣撳氨鏄井杞妸鐩稿叧绋嬪簭鍖呴兘鍒犳帀浜嗭紝濂藉潙鍟婐煒傦紝鎴戣繕浠ヤ负鏄▼搴忓寘婧愬彉鏇翠簡锛屽悗鏉ユ垜鎵句簡褰撴椂鐨勫ソ鍑犱釜绋嬪簭鍖呮簮锛岃瘯浜嗛兘涓嶈锛岄偅鏄笉鏄墍鏈夌殑绋嬪簭鍖呴兘鍒犳帀浜嗭紵鍏跺疄涓嶆槸锛屽井杞彧淇濈暀浜嗚繖绉�code>1.0.0-rc1-final鐗堟湰鐨勭▼搴忓寘锛屽叾浠栫殑鍩烘湰涓婇兘鍒犳帀浜嗭紝姣斿涓嬮潰鐨勮繖绉嶇増鏈▼搴忓寘锛�/p>
杩欎釜椤圭洰鎴戝熀鏈笂鐢ㄧ殑閮芥槸1.0.0-rc2-xxxxx
鐗堟湰鐨勭▼搴忓寘锛屾瘮杈冨潙锛屼负浠�箞鐢ㄨ繖绉嶇増鏈殑锛熶富瑕佹槸褰撴椂瑙e喅涓�簺鐗规畩闂锛屽氨涓嶈缁嗚浜嗭紝濡傛灉澶у鎰熷叴瓒g殑璇濓紝鍙互鏌ョ湅涓�a href="http://www.cnblogs.com/xishuai/category/586918.html">鐩稿叧鏂囩珷锛屽鏋滀綘鐨勯」鐩敤鐨勬槸1.0.0-rc1-final
鐗堟湰鐨勭▼搴忓寘锛岄偅涔堣繕鍘熷拰鐢熸垚搴旇鏄垚鍔熺殑銆�/p>
褰撴椂 ASP.NET Core 1.0 RC2 涓�彂甯冨嚭鏉ワ紝鎴戝紑鍙戠幆澧冨氨瀹夎鏇存柊浜嗭紝鐒跺悗鍓嶅嚑澶╄繖涓」鐩湁涓�釜 bug 闇�杩涜淇锛屾墦寮�箣鍚庡氨鏄笂闈㈣繖涓笩鏍凤紝鎵�互锛屼慨澶�bug 蹇呴』瑕佸崌绾у埌 RC2 鐗堟湰锛岃繖涔熸槸鎴戣繖娆″崌绾х殑涓昏鍘熷洜銆�/p>
涓婇潰搴熻瘽鏈夌偣澶氾紝涓昏鎯冲彂娉勫悙妲戒笅锛岃█褰掓浼狅紝鎴戜滑鍦ㄤ唬鐮佹洿鏂颁箣鍓嶏紝闇�浜嗚В涓�.NET Platform Standard 鐨勬蹇碉紝璇︾粏鍙互鐪嬫垜鍓嶄袱澶╁啓鐨勪竴绡囨枃绔狅細鐞嗚В .NET Platform Standard锛岃繖绡囨枃绔犲氨鏄垜鍦ㄥ崌绾х殑杩囩▼涓褰曠殑锛屽洜涓轰箣鍓嶅瀹冪殑涓嶄簡瑙o紝鎵�互鍚庢潵韪╀簡涓�簺鍧戯紝绠�崟鏉ヨ锛屽氨鏄�strong>浣犳兂璁╀綘鐨勫簲鐢ㄧ▼搴忓熀浜庝粈涔堝钩鍙拌繍琛岋紵鍏蜂綋鎸囩殑鏄熀纭�被搴撳拰杩愯鏃�/strong>锛屽湪 ASP.NET Core 1.0 RC2 搴旂敤绋嬪簭涓殑浣撶幇锛屽氨鏄�code>project.json涓殑frameworks
閰嶇疆锛屽鏋滀綘鐨勫簲鐢ㄧ▼搴忔槸鍩轰簬 Desktop CLR 杩愯锛�code>frameworks閰嶇疆涓�code>net461锛岄偅涔堜綘寮�彂鐨勭▼搴忓寘骞朵笉闇�瀵瑰簲鍗囩骇锛屽彧鏄浉搴旂殑鎶婂叾浠栭渶瑕佸崌绾у埌 RC2 鐗堟湰鐨勭▼搴忓寘瀵瑰簲鍗囩骇涓嬶紝浣嗗鏋滈渶瑕佽法骞冲彴锛堝熀浜�CoreCLR/CoreFx锛夛紝閭d箞鎵�湁鐨勭▼搴忓寘閮介渶瑕佽繘琛屽崌绾с�
棣栧厛锛屾垜浠渶瑕佹妸鎵�湁绋嬪簭闆嗙殑project.json
閰嶇疆锛岀敱鍘熸湁鐨勶紙绀轰緥锛夛細
{
"version": "1.0.0-*",
"description": "CNBlogs.Ad.Domain.Entities Class Library",
"authors": [ "xishuai" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": { }
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc2-16432"
}
}
淇敼涓猴紙绀轰緥锛夛細
{
"version": "1.0.0-*",
"description": "CNBlogs.Ad.Domain.Entities Class Library",
"authors": [ "xishuai" ],
"frameworks": {
"netcoreapp1.0": {
"imports": ["dnxcore50", "portable-net45+win8"]
}
},
"dependencies": {
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final"
}
}
涓婇潰涓昏鏄�code>frameworks鐨勯厤缃洿鏀癸紝骞朵笖鍘婚櫎浜�code>tags銆�code>projectUrl鍜�code>licenseUrl锛�code>netcoreapp1.0鐨勫墠韬槸dnxcore50
锛屾剰鎬濇槸璺ㄥ钩鍙帮紝涓轰粈涔堥渶瑕侀渶瑕佹坊鍔�code>imports閰嶇疆锛熶富瑕佹槸涓轰簡鍏煎锛岃缁嗙湅涓婇潰鐨勯偅绡囨枃绔犮�
frameworks
鐨勯厤缃慨鏀瑰ソ涔嬪悗锛屼笅闈㈠氨鏄▼搴忓寘鐨勭増鏈崌绾т簡锛屾垜澶ф璁板綍浜嗕竴浜涳細
Old Version | New Version |
---|---|
"EntityFramework.Core": "7.0.0-rc2-16432" | "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final" |
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc2-16432" | "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final" |
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc2-16160" | "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final" |
"Microsoft.AspNet.DataProtection.Extensions": "1.0.0-rc2-15874" | "Microsoft.AspNetCore.DataProtection.Extensions": "1.0.0-rc2-final" |
"Microsoft.AspNet.Diagnostics": "1.0.0-rc2-16303" | "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final" |
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc2-15994" | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final" |
"Microsoft.AspNet.Mvc": "6.0.0-rc2-16614" | "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final" |
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc2-16614" | "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final" |
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc2-16156" | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final" |
"Microsoft.AspNet.StaticFiles": "1.0.0-rc2-16036" | "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final" |
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc2-15905" | "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final" |
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-15905" | "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final" |
"Microsoft.Extensions.Logging": "1.0.0-rc2-15907" | "Microsoft.Extensions.Logging": "1.0.0-rc2-final" |
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15907" | "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final" |
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-15907" | "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final" |
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-16142", | "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final" |
杩樻湁涓�簺鍏朵粬鐨勫悗闈㈠啀璇翠笅锛屾垜浠彲浠ュ厛鏇存敼浠g爜锛岀劧鍚庢牴鎹�VS 2015 鐨勬彁绀衡�瀹夎瀵瑰簲绋嬪簭鍖呪�鍔熻兘锛屽彲浠ュ緢鏂逛究鐨勮繘琛屽崌绾э紝濡傚浘锛�/p>
鍘熷厛浠g爜锛�/p>
public class EFDbContext : DbContext, IDbContext
{
public EFDbContext(DbContextOptions options)
: base(options)
{ }
}
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<EFDbContext>(options => options.UseSqlServer(Configuration["data:ConnectionString"]));
}
淇敼涓猴細
public class EFDbContext : DbContext, IDbContext
{
public EFDbContext(DbContextOptions<EFDbContext> options)
: base(options)
{ }
}
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<EFDbContext>(options =>
options.UseSqlServer(Configuration["data:ConnectionString"]));
}
濡傛灉绋嬪簭闆嗕腑寮曠敤浜�code>"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final"绋嬪簭鍖咃紝闇�灏�code>frameworks淇敼濡備笅锛�/p>
"frameworks": {
"netcoreapp1.0": {
"imports": ["dnxcore50", "portable-net45+win8"]
}
}
鍚﹀垯浼氬嚭鐜颁笅闈㈢殑閿欒锛�/p>
Getting started with xUnit.net (.NET Core / ASP.NET Core)
Microsoft.AspNet.TestHost
绋嬪簭鍖咃紝鍦�.NET Core RC2 鐗堟湰琚Щ闄や簡锛屾墍浠ユ垜浠病鍔炴硶瀵�WebApi 杩涜娴嬭瘯浜嗭紙搴旇鏈夊叾浠栫殑瑙e喅鏂瑰紡锛屽緟鐮旂┒锛夛紝鍘熸湁鐨勫啓娉曪紙铏界劧杩樻槸鍙互寮曠敤1.0.0-rc1-final
鐗堟湰锛屼絾鍜�RC2 宸茬粡涓嶅吋瀹逛簡锛夛細
namespace CNBlogs.Ad.BaseTests
{
public class BaseWebApiTest
{
protected TestServer _server;
public BaseWebApiTest()
{
_server = TestServer.Create(app =>
{
var env = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
var appEnv = app.ApplicationServices.GetRequiredService<IApplicationEnvironment>();
var loggerFactory = app.ApplicationServices.GetRequiredService<ILoggerFactory>();
new CNBlogs.Ad.WebApi.Startup(env, appEnv).Configure(app, env, loggerFactory);
}, services =>
{
var connectionString = @"";
services.AddMvc();
services.Configure(connectionString);
});
}
}
}
xUnit 鍗曞厓娴嬭瘯鐨勭浉鍏充唬鐮侊紝鍩烘湰涓婁笉闇�鏇存敼锛屾垜浠彧闇�鏇存柊涓�code>project.json鐨勯厤缃紝鍘熷厛閰嶇疆锛�/p>
{
"version": "1.0.0-*",
"description": "CNBlogs.Ad.BaseTests Class Library",
"authors": [ "xishuai" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"dnx451": { }
},
"dependencies": {
"CNBlogs.Ad.WebApi": "1.0.0-*",
"CNBlogs.Ad.Infrastructure": "1.0.0-*",
"CNBlogs.Ad.Infrastructure.Interfaces": "1.0.0-*",
"EntityFramework.Core": "7.0.0-rc2-16432",
"xunit": "2.1.0",
"xunit.runner.dnx": "2.1.0-rc1-build204",
"Microsoft.AspNet.TestHost": "1.0.0-rc2-16032"
},
"commands": {
"test": "xunit.runner.dnx"
}
}
淇敼涓猴細
{
"version": "1.0.0-*",
"description": "CNBlogs.Ad.BaseTests Class Library",
"authors": [ "xishuai" ],
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
}
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"dependencies": {
"CNBlogs.Ad.Bootstrapper": "1.0.0-*",
"CNBlogs.Ad.WebApi": "1.0.0-*",
"CNBlogs.Ad.Infrastructure": "1.0.0-*",
"CNBlogs.Ad.Infrastructure.Interfaces": "1.0.0-*",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNet.TestHost": "1.0.0-rc1-final",
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-build10015"
}
}
闄や簡浣跨敤 VS 2015 鐨�Test Explorer 璺戝崟鍏冩祴璇曚箣澶栵紝鎴戜滑杩樺彲浠ヤ娇鐢ㄦ柊鐨�code>dotnet test鍛戒护銆�/p>
澧炲姞Program.cs
锛�/p>
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
骞舵坊鍔�code>web.config锛堢Щ闄�code>wwwroot鐩綍涓嬬殑web.config
锛夛細
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
涔嬪墠寮曠敤鐨�code>"Serilog.Framework.Logging": "1.0.0-*"鏃ュ織缁勪欢锛岀幇鍦ㄥ凡琚純鐢紝闇�閲嶆柊寮曠敤锛�/p>
"Serilog": "2.0.0-rc-563",
"Serilog.Extensions.Logging": "1.0.0-rc2-10104",
"Serilog.Sinks.RollingFile": "2.0.0-rc-703"
鏃ュ織浠g爜閰嶇疆锛�/p>
public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Error()
.WriteTo.RollingFile(Path.GetFullPath("logs/log-{Date}.txt"))
.CreateLogger();
}
鍘婚櫎浜嗕箣鍓嶇殑IApplicationEnvironment appEnv
鍙傛暟锛屽洜涓虹幇鍦�code>Startup宸蹭笉鏀寔锛屽鏋滀娇鐢ㄧ殑璇濓紝浼氱洿鎺ユ姏鍑哄紓甯革紝WriteTo.RollingFile
鏄棩蹇楀啓鍏ョ殑鏂瑰紡锛岀幇鍦�code>Serilog閮借繘琛屾媶鍒嗕簡鍚勭绋嬪簭鍖咃紝浠�code>Serilog.Sinks.XXXX鐨勫舰寮忥紝璇︽儏鏌ョ湅锛�a href="https://github.com/serilog" class="uri">https://github.com/serilog
appsettings.json
鏂囦欢涓殑Logging: LogLevel
閰嶇疆鏇存敼锛�/p>
Old Levels | New Levels |
---|---|
Critical | Critical |
Error | Error |
Warning | Warning |
Information | Information |
Verbose | Debug |
Debug | Trace |
绉婚櫎app.UseIISPlatformHandler();
閰嶇疆銆�/p>
_ViewImports.cshtml
鏂囦欢涓殑锛�/p>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers`
淇敼涓猴細
@addTagHelper *, Microsoft.AspNet.Mvc.TagHelpers`
骞跺紩鐢�code>"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final"绋嬪簭鍖呫�
CookieAuthentication
閰嶇疆鏇存柊涓猴細
var dataProtection = Microsoft.AspNetCore.DataProtection.DataProtectionProvider.Create(
new DirectoryInfo(@"C:\shared-auth-ticket-keys"), x => x.SetApplicationName("XXXXX"));
var cookieOptions = new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
CookieHttpOnly = true,
ExpireTimeSpan = TimeSpan.FromMinutes(43200),
CookieName = ".XXXXX",
CookiePath = "/",
DataProtectionProvider = dataProtection
};
app.UseCookieAuthentication(cookieOptions);
瀹屾暣鐨�code>Startup.cs浠g爜锛�/p>
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using CNBlogs.Ad.Bootstrapper;
using Serilog;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Serilog.Sinks.RollingFile;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using AutoMapper
namespace CNBlogs.Ad.Web
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Error()
.WriteTo.RollingFile(Path.GetFullPath("logs/log-{Date}.txt"))
.CreateLogger();
}
public IConfigurationRoot Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddDbContext<EFDbContext>(options =>
options.UseSqlServer(Configuration["data:ConnectionString"]));
services.AddEnyimMemcached();
Mapper.Initialize(cfg =>
{
cfg.CreateMap<CNBlogs.Ad.Domain.Entities.AdText, AdTextDTO>();
});
services.AddTransient<IUnitOfWork, UnitOfWork>();
services.AddScoped<IDbContext, EFDbContext>();
services.AddTransient<IUserService, UserService>();
services.AddTransient<IAdTextRepository, AdTextRepository>();
services.AddAuthentication();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
var dataProtection = Microsoft.AspNetCore.DataProtection.DataProtectionProvider.Create(
new DirectoryInfo(@"C:\shared-auth-ticket-keys"), x => x.SetApplicationName("XXXX"));
var cookieOptions = new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
CookieHttpOnly = true,
ExpireTimeSpan = TimeSpan.FromMinutes(43200),
CookieName = "XXXX",
CookiePath = "/",
DataProtectionProvider = dataProtection
};
app.UseCookieAuthentication(cookieOptions);
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Default",
template: "{controller}/{action}/{id?}");
});
}
}
}
棣栧厛锛孉SP.NET Core 1.0 RC2 鐨勫彂甯冩湁涓ょ鏂瑰紡锛�/p>
榛樿鏄�Portable 鐨勫彂甯冩柟寮忥紝鍜�ASP.NET 5 RC1 鎵�笉鍚岀殑鏄紝ASP.NET Core 1.0 RC2 鍙兘閫氳繃dotnet publish
鐨勫懡浠よ繘琛屽彂甯冦�
project.json
閰嶇疆浠g爜锛�/p>
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
}
//....
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-*",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
dotnet publish
鍛戒护鍙戝竷锛�/p>
鍙戝竷鐢熸垚鐩綍涓猴細\CNBlogs.Ad.Web\bin\Debug\netcoreapp1.0\publish
锛岀洰褰曠粨鏋勶細
runtimes
鐩綍涓嬫湁鍚勪釜骞冲彴鐨�code>native鏂囦欢锛屽叾浣滅敤灏辨槸鍗虫椂缂栬瘧锛�code>publish鐩綍闄や簡鍩烘湰鐨勭▼搴忛泦涔嬪锛屽苟娌℃湁杩愯鏃剁殑鏂囦欢銆�/p>
鏍圭洰褰曚笅鐨�code>web.config閰嶇疆锛�/p>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\CNBlogs.Ad.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
濡傛灉鏄�Self-Contained 鏂瑰紡鍙戝竷锛屾垜浠渶瑕佸湪project.json
鏂囦欢涓坊鍔�code>runtimes閰嶇疆锛堝弬鑰冿細Types of portability in .NET Core锛夛細
"runtimes": {
"win10-x64": {},
"osx.10.11-x64": {}
}
骞跺幓闄�code>dependencies绋嬪簭鍖呯殑platform
閰嶇疆锛�/p>
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"//鍘婚櫎
}
dotnet publish
鍛戒护閲嶆柊鍙戝竷锛岀洰褰曠粨鏋勶細
鍜屼笂闈㈢殑 Portable 鍙戝竷涓嶅悓鐨勬槸锛屽彂甯冩枃浠朵腑澶氫簡coreclr.dll
绛夛紝骞朵笖鐢�code>CNBlogs.Ad.WebApi.dll鍙樻垚浜�code>CNBlogs.Ad.WebApi.exe锛屾垜浠敋鑷崇洿鎺ュ彲浠ョ偣鍑�code>CNBlogs.Ad.WebApi.exe杩愯缃戠珯锛屾牴鐩綍涓嬬殑web.config
閰嶇疆锛�/p>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\CNBlogs.Ad.WebApi.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
濡傛灉鏄�Self-Contained 鏂瑰紡鍙戝竷锛屾湇鍔″櫒鍙渶瑕佸畨瑁�ASP.NET Core Module锛岀浉鍏虫枃妗o細https://github.com/aspnet/IISIntegration/issues/105
濡傛灉鏄�Portable 鏂瑰紡鍙戝竷锛屾湇鍔″櫒鍒欓渶瑕佸畨瑁�.NET Core RC2
IIS 鍜屼箣鍓嶇殑 ASP.NET 5 RC1 鍙戝竷閰嶇疆涓�牱锛屽垱寤�Web 绔欑偣锛岀劧鍚庣粦瀹氬彂甯冪洰褰曞氨琛岋紝搴旂敤绋嬪簭姹犵殑妯″紡闇�鏀逛负鈥滄棤浠g爜鎵樼鈥濄�