Secrets of project.json file

As you may already notice ASP.NET Core is using project.json files to controls almost all aspects of the project. It contains lot of section (which I will describe bellow) with full support of intellisense. That file is also synchronized with Solution Explorer – removing referenced from file will automatically update References node in Solution Explorer.

Here is the list of project.json sect:ion which can be used to configure you project:

name – this is the name of the project used for assembly name and the name of the package

description – longer description of the project used in assembly properties

copyright – copyright information’s used in assembly properties

title – this is friendly name of the project (not allowed when using name property)

entryPoint – the entrypoint method of the project (main by default)

testRunner – here you can configure name of test runner to be used with project (for example NUnit or xUnit)

authors - array of string with the name of the application authors

language – language of the project

embedInteropTypes – set this to true if you want to embed COM interop types in the assembly

preprocess – specifies which files will be included in preprocessing

1: {

2:"preprocess": "compiler/preprocess/**/*.cs"

3: }

shared – specifies which files are shared (used for library export)

dependencies – an object that defines the package dependencies of the project

1:"dependencies": {

2:"System.Reflection.Metadata": "1.3.0",

3:"Microsoft.Extensions.JsonParser.Sources": {

4:"type": "build",

5:"version": "1.0.0-rc2-20221"

6: },

7:"Microsoft.Extensions.HashCodeCombiner.Sources": {

8:"type": "build",

9:"version": "1.1.0-alpha1-21456"

10: },

11:"Microsoft.Extensions.DependencyModel": "1.0.0-*"

12: }

tools – object that defines package dependencies that are used as tools for the current project. Tools can for example include code generators or post-build tools that perform tasks related to packing.

scripts – here you can define scripts to be run during the build process. Each key of this object identifies where in the build the script is run. Here is the list of supported events:

precompile

postcompile

prepublish

postpublish

1: {

2:"scripts": {

3:"precompile": "generateCode.cmd"

4:"postcompile": [ "obfuscate.cmd", "removeTempFiles.cmd" ]

5: }

6: }

buildOptions – here you can define properties which can control various aspects of compilation. Full list of options can be found here

publishOptions – properties for compilation configuration such as:

include

exclude – which files to exclude from the build

includeFiles

excludeFiles

builtIns

mappings

runtimeOptions - list of parameters to be provided to the runtime during initialization. More details here.

packOptions – defines options pertaining to the packaging of the project output into a NuGet package

analyzerOptions – object with properties used by code analysers

configurations – here you can define different configurations for the project such as Debug or Relese. Here is the example:

1:"configurations": {

2:"Release": {

3:"buildOptions": {

4:"allowUnsafe": false

5: }

6: }

7: }

frameworks – list of frameworks supported by this project. Example bellow and more details here.

1:"frameworks": {

2:"netcoreapp1.0": {

3:"imports": [

4:"dotnet5.6",

5:"dnxcore50",

6:"portable-net45+win8"

7: ]

8: }

9: }

Leave a comment

Coment fields

Name

Email

Comment

Project.Json Tester

8/22/2016 6:25 AM

Hi there
do you have anywhere you can point to where valid commands exists for a postcompile file?
I want to get the build output directory for example, in my cmd file, but nothing I am doing is working.
Any tips?