How to set default namespace in projects using project.json (.xproj)

In the standard .csproj you can go to properties and set the default namespace. How can this be achieved in a .xproj project using project.json ?

+7
asp.net-core .net-core project
source share
2 answers

AFAIK this cannot be done using project.json. You can do this with xproj just as you did with csproj. Right-click it in Visual Studio and on the Application tab, change the Default namespace .

+7
source share

With asp.net core 1.0.1, you can set the default namespace in the project.json file as follows:

 "tooling": { "defaultNamespace": "Your.Name.Space" } 

yeoman asp.net generator will respect this defaultNamespace when creating new classes

For the new Visual Studio 2017 csproj toolkit, you can add the following XML to change the default namespace (up at the top level <PropertyGroup> link ):

 <PropertyGroup> <Optimize>true</Optimize> ... <RootNamespace>My.Root.Namespace</RootNamespace> </PropertyGroup> 

This is necessary only if your .csproj file_name does not match your intended root namespace for the project.

+9
source share

All Articles