Projects
Project structure
- Solution/
- .sln
- global.json - lists sdk (optional)
- test\
- Test Projects (one or more)
- src - source
- {Project}\ -NB: folder name==assembly name
- bin\Debug\netcoreapp3.1 - compiled dlls
- publish\ -
- Controllers\
- Views\ - only MVC, not webapi, obviously
- wwwroot\ - static files for deployment
- css\ images\ js\ as applicable
- web.config - tells IIS to launch dotnet
- appsettings.json
- Program.cs - static vod Main. Before .net6, calls startup. After net6, this does the startup
- Startup.cs - startup file (like global.asax) (Not in .net 6)
- {project}.csproj - msbuild.
- bin\Debug\netcoreapp3.1 - compiled dlls
- {Project}\ -NB: folder name==assembly name
Main changes:
- There's a wwwroot folder for the static javascript/css/images
- There's no web.config. It only appears when you publish.
- The global.asax is gone; now there's Program.cs and (pre net6) Startup.cs - see more
Publishing
You can "Publish" from VS as before, or "dotnet publish".
- You publish to (default) /bin/Release/Publish/
dotnet publish default is Debug\netcoreapp3.1\publish\, so add "-c release" for a release build! - Unlike classic asp.net, there is no "bin" folder- the dlls are toplevel, the static files ("wwwroot") are below.
The structure (reverse alphabetic order, to explain it better):
- web.config (See IIS description)
- appsettings.json for configuration
- *.dll. All dlls are top level. The startup is an .exe; views are in the .Views.dll
- wwwroot\ - static files.
Normally it's a FDD-framework dependent deployment, using an installed version of dotnet, It can be a SCD-self-contained deployment, including the .net Core runtime, by specifying the RuntimeIdentifiers (eg "Win10-x64") in csproj and your "dotnet publish -r win10-x64".
Project.json + csproj
VS2015's project.json includes parts that were originally in the csproj, packages.config, and project.nuspec (but other bits were in project.xproj).
In VS2017+, we have csproj.
- buildOptions with "emitEntryPoint" means it is runnable (by calling static void Main), not a library
- The dependency and framework change from an abstract API (netstandard.Library/netstandard) to an implementation (Microsoft.NETCore.App /netcoreapp). See about versions below.
- Dependencies and frameworks:
- dependencies: other nuget packages
In old .net this was <Reference /> in csproj and the list in packages.config - frameworks: what runs the code
In old .csproj this was <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- dependencies: other nuget packages
With VS 2017, this changes to csproj (NB: VS 2015= only project.json, VS 2017= only project.csproj)