在Visual Studio中将现有.NET Framework项目迁移至.NET Core 1.1 Preview 1
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)
{
//..
}
}
在Visual Studio中将现有.NET Framework项目迁移至.NET Core 1.1 Preview 1的更多相关文章
- Visual Studio 2013新建ASP.NET项目使用Empty模板,在页面中使用验证控件出错的解决方案
Visual Studio 2013新建ASP.NET项目使用Empty模板,在页面中使用验证控件,运行页面,会出现如下的错误: 错误原因 VisualStudio 2012(或2013) WebFo ...
- Visual Studio 中的 .NET Framework 类库
Visual Studio 中的 .NET Framework 类库 .NET Framework 类库由命名空间组成.每个命名空间都包含可在程序中使用的类型:类.结构.枚举.委托和接口. 当您在 V ...
- Visual Studio 2015 与GitLab 团队项目与管理【2】
前一篇介绍了Git服务器的搭建,我采用的是CentOS7-64位系统,git版本管理使用的是GitLab,创建管理员密码后进入页面. 创建Users,需要记住Username和邮箱,初始密码可以由管理 ...
- visual studio 2015将已有项目添加到码云(gitee)
visual studio 2015将已有项目添加到码云的步骤包括:gitee新建项目.清空项目及VS发布项目 1.gitee新建项目 2.清空项目 清空项目则会将vs项目的master分支发布到gi ...
- SharpDX初学者教程第1部分:在Visual Studio 2013中设置SharpDX项目
原文 http://www.johanfalk.eu/blog/sharpdx-tutorial-part-1-setting-up-a-sharpdx-project-in-visual-studi ...
- Visual Studio 2017-2019版本创建C#项目时没有创建网站这一选项?
通过了解以后发现Visual Studio 2017之后的版本在新建选项中已经不再有这一选择项了. 解决办法: 1.在创建新项目的面板滑倒最下面,---> 安装多个人工具和功能 2.这时已经打开 ...
- NET Framework项目移植到NET Core上遇到的一系列坑
原文:NET Framework项目移植到NET Core上遇到的一系列坑 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https: ...
- NET Framework项目移植到NET Core上踩的坑(1)
本文章向大家介绍NET Framework项目移植到NET Core上遇到的一系列坑,主要包括NET Framework项目移植到NET Core上遇到的一系列坑使用实例.应用技巧.基本知识点总结和需 ...
- .NET项目迁移到.NET Core操作指南
为什么要从.NET迁移到.NET Core? .NET Core提供的特性 .NET Core性能提升 .NET如何迁移到.NET Core? 迁移工作量评估(API兼容性分析) 迁移方案制定 通过类 ...
随机推荐
- elasticsearch5.0.0 安装插件及配置过程
elasticsearch5.0.0 安装插件及配置过程 由于es5.0是里程碑式的更新,所以很多变化的地方,暂时我就插件安装遇到的问题记录一下. 插件安装命令 2.3版本的安装命令 安装Marvel ...
- Delphi中ExtractFilePath、ParamStr以及更多文件/目录操作涉及的函数。附加对应的例子
先介绍ExtractFilePath和ParamStr ParamStr 该函数的原型是:function paramstr(i: Integer): String; 对于任何的application ...
- Python 实现隐藏文件夹、文件操作
Python通过win32api 可以实现操作文件夹文件操作,获取属性,修改属性 1.获取属性 通过win32api.GetFileAttributes 方法可以获取属性值 import win32c ...
- 解决升级PHP7后 微信公众号收不到消息
服务器配置Linux+Nginx+PHP5.5+mysql index方法配置微信的关注回复.菜单事件.多客服.自动回复等 public function actionIndex() { if (is ...
- Selenium通过WebDriver控制IE浏览器出错 Browser zoom level was set to 109%. It should be set to 100%
错误信息: WebDriverException: Message: Unexpected error launching Internet Explorer. Browser zoom level ...
- vue简单使用
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...
- fat32转ntfs
convert c: /fs:ntfs 下了个维基的zim,7G,fat32放不下 :( Microsoft Windows [版本 6.1.7600] 版权所有 (c) 2009 Microsoft ...
- 初识node.js
Node.js不是一种语言:不是框架:也不是工具.它是用于运行基于JavaScript应用程序的运行时环境.
- MSP430FR4133/4131/4132单片机破解芯片解密多少钱?
德州仪器MSP430FR4133/4131/4132单片机破解芯片解密多少钱? MSP430FR4133.MSP430FR4131.MSP430FR4132 ####[微信:icpojie]#### ...
- poj分类 很好很有层次感。
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...