[asp.net core]project.json(1)
摘要
前面介绍了使用vs2015新建asp.net core web的内容,这篇文章学习下project.json文件的内容。
project.json
原文:https://docs.microsoft.com/zh-cn/dotnet/articles/core/tools/project-json
project.json文件用来定义asp.net core项目的元数据,编译信息和依赖。在本篇文章中,你可以看到你能在project.json中定义的所有属性列表。
Note
.NET Core核心工具将在未来的发布版本中从project.json迁移到MSBuild-based项目。建议仍旧在新的.NET Core项目中使用project.json,但在发布的时候,将会把project转换为MSBuild。
For more information, see the Changes to project.json post on the .NET blog and the Using MSBuild to build .NET Core projects topic.
project.json包括的内容如下
{
"name": String,
"version": String,
"description": String,
"copyright": String,
"title": String,
"entryPoint": String,
"testRunner": String,
"authors": String[],
"language": String,
"embedInteropTypes": Boolean,
"preprocess": String or String[],
"shared": String or String[],
"dependencies": Object {
version: String,
type: String,
target: String,
include: String,
exclude: String,
suppressParent: String
},
"tools": Object,
"scripts": Object,
"buildOptions": Object {
"define": String[],
"nowarn": String[],
"additionalArguments": String[],
"warningsAsErrors": Boolean,
"allowUnsafe": Boolean,
"emitEntryPoint": Boolean,
"optimize": Boolean,
"platform": String,
"languageVersion": String,
"keyFile": String,
"delaySign": Boolean,
"publicSign": Boolean,
"debugType": String,
"xmlDoc": Boolean,
"preserveCompilationContext": Boolean,
"outputName": String,
"compilerName": String,
"compile": Object {
"include": String or String[],
"exclude": String or String[],
"includeFiles": String or String[],
"excludeFiles": String or String[],
"builtIns": Object,
"mappings": Object
},
"embed": Object {
"include": String or String[],
"exclude": String or String[],
"includeFiles": String or String[],
"excludeFiles": String or String[],
"builtIns": Object,
"mappings": Object
},
"copyToOutput": Object {
"include": String or String[],
"exclude": String or String[],
"includeFiles": String or String[],
"excludeFiles": String or String[],
"builtIns": Object,
"mappings": Object
}
},
"publishOptions": Object {
"include": String or String[],
"exclude": String or String[],
"includeFiles": String or String[],
"excludeFiles": String or String[],
"builtIns": Object,
"mappings": Object
},
"runtimeOptions": Object {
"configProperties": Object {
"System.GC.Server": Boolean,
"System.GC.Concurrent": Boolean,
"System.GC.RetainVM": Boolean,
"System.Threading.ThreadPool.MinThreads": Integer,
"System.Threading.ThreadPool.MaxThreads": Integer
},
"framework": Object {
"name": String,
"version": String,
},
"applyPatches": Boolean
},
"packOptions": Object {
"summary": String,
"tags": String[],
"owners": String[],
"releaseNotes": String,
"iconUrl": String,
"projectUrl": String,
"licenseUrl": String,
"requireLicenseAcceptance": Boolean,
"repository": Object {
"type": String,
"url": String
},
"files": Object {
"include": String or String[],
"exclude": String or String[],
"includeFiles": String or String[],
"excludeFiles": String or String[],
"builtIns": Object,
"mappings": Object
}
},
"analyzerOptions": Object {
"languageId": String
},
"configurations": Object,
"frameworks": Object {
"dependencies": Object {
version: String,
type: String,
target: String,
include: String,
exclude: String,
suppressParent: String
},
"frameworkAssemblies": Object,
"wrappedProject": String,
"bin": Object {
assembly: String
}
},
"runtimes": Object,
"userSecretsId": String
}
name
类型:String
该项目的名称,用于程序集名称以及包的名称。如果未指定此属性,则使用顶级文件夹名称。
例子:
{
"name": "MyLibrary"
}
description
类型:String
对项目的更详细的描述。用于程序集属性。
例子:
{
"description": "This is my library and it's really great!"
}
copyright
类型:String
项目版本信息,用于程序集属性。
例子:
{
"copyright": "Fabrikam 2016"
}
title
类型:String
项目别名(友好名称),可以包含在使用name属性时,不允许包含的空格和特殊字符。用于程序集属性。
例子:
{
"title": "My Library"
}
entryPoint
类型:String
项目的默认的main进入方法。
例子:
{
"entryPoint": "ADifferentMethod"
}
testRunner
类型:String
测试程序的名称,例如NUnit或者xUnit,使用Project.json的该配置,标识该项目是一个测试项目。
例子:
{
"testRunner": "NUnit"
}
authors
类型:String[]
项目所属人名称。
例子:
{
"authors": ["Anne", "Bob"]
}
language
类型:String
项目语言类型,对应于“中性语言”的编译参数。
例子:
{
"language": "en-US"
}
embedInteropTypes
类型:Boolean
true:嵌入com组件,否则为false。
例子:
{
"embedInteropTypes": true
}
preprocess
类型:带有全局通配符的String或者String[]
定义在预编译的时候应包含哪些文件。
例子:
{
"preprocess": "compiler/preprocess/**/*.cs"
}
shared
类型:带有全局通配符的String或者String[]
定义哪些文件被共享,用于类库导出。
例子:
{
"shared": "shared/**/*.cs"
}
dependencies
类型:Object
定义了项目依赖的包,包名称作为键名,值为版本信息。For more information, see the Dependency resolution article on the NuGet documentation site.
例子:
"dependencies": {
"System.Reflection.Metadata": "1.3.0",
"Microsoft.Extensions.JsonParser.Sources": {
"type": "build",
"version": "1.0.0-rc2-20221"
},
"Microsoft.Extensions.HashCodeCombiner.Sources": {
"type": "build",
"version": "1.1.0-alpha1-21456"
},
"Microsoft.Extensions.DependencyModel": "1.0.0-*"
}
version
Type: String
Specifies the version or version range of the dependency. Use the * wildcard to specify a floating dependency version.
For example:
"dependencies": {
"Newtonsoft.Json": {
"version": "9.0.1"
}
}
type
Type: String
Specifies the type of the dependency. It can be one of the following values: default
, build
or platform
. The default value is default
.
build
is known as a development dependency and is only used for build-time. It means that the package should not be published or added as a dependency to the output .nupkg
file. It has the same effect of setting supressParent to all
.
platform
references the shared SDK. For more information, see the section on "Deploying a framework-dependent deployment with third-party dependencies" on the .NET Core Application Deployment topic.
For example:
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
target
Type: String
Restricts the dependency to match only a project
or a package
.
include
Type: String
Includes parts of dependency packages. It can use one or more of the following flags: all
, runtime
, compile
, build
, contentFiles
, native
, analyzers
, or none
. Multiple flags are defined by a comma-delimited list. For more information, see the Managing dependency package assets specification on the NuGet repo.
For example:
{
"dependencies": {
"packageA": {
"version": "1.0.0",
"include": "runtime"
}
}
}
exclude
Type: String
Excludes parts of dependency packages. It can be one or more of the following flags: all
, runtime
, compile
, build
, contentFiles
, native
, analyzers
, or none
. Multiple flags are defined by a comma-delimited list. For more information, see the Managing dependency package assets specification on the NuGet repo.
For example:
{
"dependencies": {
"packageA": {
"version": "1.0.0",
"exclude": "contentFiles"
}
}
}
supressParent
Type: String
Defines additional excludes for consumers of the project. It can be one the following flags: all
, runtime
, compile
, build
, contentFiles
, native
, analyzers
, or none
. For more information, see the Managing dependency package assets specification on the NuGet repo.
{
"dependencies": {
"packageA": {
"version": "1.0.0",
"suppressParent": "compile"
}
}
}
tools
Type: Object
An object that defines package dependencies that are used as tools for the current project, not as references. Packages defined here are available in scripts that run during the build process, but they are not accessible to the code in the project itself. Tools can for example include code generators or post-build tools that perform tasks related to packing.
For example:
{
"tools": {
"MyObfuscator": "1.2.4"
}
}
scripts
Type: Object
An object that defines scripts run during the build process. Each key in this object identifies where in the build the script is run. Each value is either a string with the script to run or an array of strings containing scripts that will run in order. The supported events are:
- precompile
- postcompile
- prepublish
- postpublish
For example:
{
"scripts": {
"precompile": "generateCode.cmd",
"postcompile": [ "obfuscate.cmd", "removeTempFiles.cmd" ]
}
}
buildOptions
Type: Object
An object whose properties control various aspects of compilation. The valid properties are listed below. Can also be specified per target framework as described in the frameworks section.
For example:
"buildOptions": {
"allowUnsafe": true,
"emitEntryPoint": true
}
define
Type: String[]
A list of defines such as "DEBUG" or "TRACE" that can be used in conditional compilation in the code.
For example:
{
"buildOptions": {
"define": ["TEST", "OTHERCONDITION"]
}
nowarn
Type: String[]
A list of warnings to ignore.
For example:
{
"buildOptions": {
"nowarn": ["CS0168", "CS0219"]
}
}
This ignores the warnings The variable 'var' is assigned but its value is never used
and The variable 'var' is assigned but its value is never used
additionalArguments
Type: String[]
A list of extra arguments that will be passed to the compiler.
For example:
{
"buildOptions": {
"additionalArguments": ["/parallel", "/nostdlib"]
}
}
warningsAsErrors
Type: Boolean
true
to treat warnings as errors; otherwise, false
. The default is false
.
For example:
{
"buildOptions": {
"warningsAsErrors": true
}
}
allowUnsafe
Type: Boolean
true
to allow unsafe code in this project; otherwise, false
. The default is false
.
For example:
{
"buildOptions": {
"allowUnsafe": true
}
}
emitEntryPoint
Type: Boolean
true
to create an executable; false
to produce a library. The default is false
.
For example:
{
"buildOptions": {
"emitEntryPoint": true
}
}
optimize
Type: Boolean
true
to enable the compiler to optimize the code in this project; otherwise, false
. The default is false
.
For example:
{
"buildOptions": {
"optimize": true
}
}
platform
Type: String
The name of the target platform, such as AnyCpu, x86 or x64.
For example:
{
"buildOptions": {
"platform": "x64"
}
}
languageVersion
Type: String
The version of the language used by the compiler: ISO-1, ISO-2, 3, 4, 5, 6, or Default.
For example:
{
"buildOptions": {
"languageVersion": "5"
}
}
keyFile
Type: String
The path for the key file used for signing this assembly.
For example:
{
"buildOptions": {
"keyFile": "../keyfile.snk"
}
}
delaySign
Type: Boolean
true
to delay signing; otherwise, false
. The default is false
.
For example:
{
"buildOptions": {
"delaySign": true
}
}
[asp.net core]project.json(1)的更多相关文章
- [asp.net core]project.json(2)
摘要 上篇文章介绍了project.json中的一部分属性.属性真的比较多,所以分开了,考虑到其中的英文比较简单,也不再进行翻译了,从英文原文中,直接粘贴过来了. project.json(1) pr ...
- ASP.NET Core的配置(5):配置的同步[ 实例篇]
ConfigurationBuilder在生成以Configuration对象的时候会利用注册其中的ConfigurationProvider加载原始的配置数据,那么一旦配置源中的数据发生变化,应用程 ...
- ASP.NET Core的配置(4):多样性的配置来源[下篇]
我们在上篇和中篇对配置模型中默认提供的各种ConfigurationProvider进行了深入详尽的介绍,如果它们依然不能满足项目中的配置需求,我们可以还可以通过自定义ConfigurationPro ...
- ASP.NET Core的配置(3): 将配置绑定为对象[上篇]
出于编程上的便利,我们通常不会直接利用ConfigurationBuilder创建的Configuration对象读取某个单一配置项的值,而是倾向于将一组相关的配置绑定为一个对象,我们将后者称为Opt ...
- ASP.NET Core的配置(1):读取配置信息
提到"配置"二字,我想绝大部分.NET开发人员脑海中会立马浮现出两个特殊文件的身影,那就是我们再熟悉不过的app.config和web.config,多年以来我们已经习惯了将结构化 ...
- ASP.NET Core的配置(5):配置的同步[设计篇]
本节所谓的"配置同步"主要体现在两个方面:其一,如何监控配置源并在其变化的时候自动加载其数据,其目的是让应用中通过Configuration对象承载的配置与配置源的数据同步:其二. ...
- ASP.NET Core的配置(4):多样性的配置来源[中篇]
我们在本篇文章中会介绍三种针对物理文件的ConfiguationProvider,它们分别是针对JSON文件的JsonConfiguationProvider,针对XML文件的XmlConfiguat ...
- ASP.NET Core的配置(4):多样性的配置来源[上篇]
较之传统通过App.config和Web.config这两个XML文件承载的配置系统,ASP.NET Core采用的这个全新的配置模型的最大一个优势就是针对多种不同配置源的支持.我们可以将内存变量.命 ...
- ASP.NET Core的配置(2):配置模型详解
在上面一章我们以实例演示的方式介绍了几种读取配置的几种方式,其中涉及到三个重要的对象,它们分别是承载结构化配置信息的Configuration,提供原始配置源数据的ConfigurationProvi ...
随机推荐
- Spark MLib 基本统计汇总 1
1. 概括统计 summary statistics MLlib支持RDD[Vector]列式的概括统计,它通过调用 Statistics 的 colStats方法实现. colStats返回一个 ...
- oracle数据库开启的时候 是先开监听还是先开主服务,关数据库的时候呢???
启动的时候无所谓先后,关闭的话 1.首先是关闭监听(让远程客户端无法再连进来):2.发出一个系统检查点,让数据文件和控制文件的系统修改号统一:(alter system checkpoint;)3.s ...
- IOS开发中UI编写方式——code vs. xib vs.StoryBoard
最近接触了几个刚入门的iOS学习者,他们之中存在一个普遍和困惑和疑问,就是应该如何制作UI界面.iOS应用是非常重视用户体验的,可以说绝大多数的应用成功与否与交互设计以及UI是否漂亮易用有着非常大的关 ...
- 【poj2741】 Colored Cubes
http://poj.org/problem?id=2741 (题目链接) 题意 给出n个骰子,每一面都有一种颜色,问最少更改多少个面的颜色可以使所有骰子通过旋转后完全相同. solution 迷之d ...
- BZOJ1407 [Noi2002]Savage
Description Input 第1行为一个整数N(1<=N<=15),即野人的数目. 第2行到第N+1每行为三个整数Ci, Pi, Li表示每个野人所住的初始洞穴编号,每年走过的洞穴 ...
- 轻量级Web API实现,带接口界面的Jayrock JsonRPC接口组件升级版
升级功能如下: 1.增加模块名称.输入参数.输出参数注释 2.增加Sign验证.输入数据解密.输出数据解密重写方法 3.增加集成Demo规范 4.增加模块分类.接口快速定位.接口调用说明.接口输入输出 ...
- ping: icmp open socket: Operation not permitted的解决办法
这个是root权限造成的,我们从 ls -l /bin/ping 可以看出 指向了root用户. 那么我们在使用时,有如下操作: 1.直接在前面加sudo sudo ping 192.168.199. ...
- dedecms /member/mtypes.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Dedecms会员中心注入漏洞 Relevant Link http:/ ...
- 净捡软柿子捏--jQuery
恩现在是在学习阶段,所以还只是一个小小的搬运工, 大部分参考自 http://www.w3school.com.cn/ 和http://www.zhangxinxu.com/ 超级好的两个学习网站,因 ...
- @EmbeddedId和@idClass的区别
@idClass 使复合主键类成为非嵌入类,使用 @IdClass 批注为实体指定一个复合主键类(通常由两个或更多基元类型或 JDK 对象类型组成).从原有数据库映射时(此时数据库键由多列组成),通常 ...