In a standard .csproj
you could go into properties and set the default namespace. How can this be achieved in a .xproj
project using project.json
?
You can change the default namespace: -> Project -> XXX Properties... Instead of Find/Replace, you can also right click the namespace in code and Refactor->Rename. my Default Namespace textbox in project properties is disabled.
The project. json file used by NuGet is a subset of that found in ASP.NET Core projects. In ASP.NET Core project. json is used for project metadata, compilation information, and dependencies.
Right click your project and select "Edit ProjectName. csproj" to view the file.
With ASP.NET Core 1.0.1, you can set your default namespace in the project.json
file as follows:
"tooling": {
"defaultNamespace": "Your.Name.Space"
}
The yeoman ASP.NET generator will respect this defaultNamespace
when generating new classes.
For the new Visual Studio 2017 csproj
tooling, you can add the following XML to change your default namespace (up in the top level <PropertyGroup>
reference):
<PropertyGroup>
<Optimize>true</Optimize>
...
<RootNamespace>My.Root.Namespace</RootNamespace>
</PropertyGroup>
This is only necessary if your .csproj filename does not match your intended root namespace for the project.
AFAIK this can't be done with a project.json. You can do it with an xproj the same way you used to do it with a csproj though. Right click it in Visual Studio, and on the Application tab, change the Default namespace
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With