文章出處
文章列表
1)下載安裝包含 .NET Core 1.1 Preview 1 的 SDK:Windows x64 安裝包(下載地址列表)
2)下載最新 VS 2015 NuGet 插件:https://dist.nuget.org/index.html
3)創建一個擴展名位 .sln 的空白文件,將以下內容復制粘貼到這個 .sln 文件中。
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8BC01464-6079-4603-881A-9F8716BA6F7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BC01464-6079-4603-881A-9F8716BA6F7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BC01464-6079-4603-881A-9F8716BA6F7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BC01464-6079-4603-881A-9F8716BA6F7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
這樣就創建了一個空白的 .NET Core 解決方案文件。
3)在各個VS項目文件夾(.csproj文件所在的文件夾)中創建擴展名位 .xproj 的空文件,將下面的內容復制/粘貼至其中,并將 RootNamespace 的值設置為當前項目的命名空間。
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup> <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> <PropertyGroup Label="Globals"> <ProjectGuid>8bc01464-6079-4603-881a-9f8716ba6f7d</ProjectGuid> <RootNamespace></RootNamespace> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup> <SchemaVersion>2.0</SchemaVersion> </PropertyGroup> <ItemGroup> <DnxInvisibleContent Include="bower.json" /> <DnxInvisibleContent Include=".bowerrc" /> <DnxInvisibleContent Include="ConnectionString.config" /> <DnxInvisibleContent Include="packages.config" /> <DnxInvisibleContent Include="Web.config" /> </ItemGroup> <Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" /> </Project>
4)在各個項目文件夾中添加如下包含基本配置的 project.json 文件:
{ "dependencies": { "Microsoft.NETCore.App": "1.1.0-preview1-*" }, "frameworks": { "netcoreapp1.1": { "imports": [ "portable-net45+win8+wp8" ] } } }
5)對于 MVC 或 Web API 項目
5.1)在 project.json 中添加 buildOptions, runtimeOptions 與 publishOptions 的配置
"buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "publishOptions": { "include": [ "wwwroot", "web.config" ] },
5.2)添加 Program.cs 與 Startup.cs 文件
Program.cs
public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseUrls("http://*:5000") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
Startup.cs
public class Startup { public Startup(IHostingEnvironment env) { //.. } public IConfigurationRoot Configuration { get; } public void ConfigureServices(IServiceCollection services) { //.. } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //.. } }
文章列表
全站熱搜