-
Notifications
You must be signed in to change notification settings - Fork 0
.NET
Command | Description |
---|---|
dotnet --list-sdks |
Shows which .NET SDKs have been installed to the machine |
dotnet new list |
Displays names of templates that can be generated. A generator similar to the one provided with React and Vue CLI tools. Will include full app templates such as ASP.NET Core, ASP.NET Core with Angular (tagged as SPA), Blazor Server App, and Blazor WebAssembly App. Will also include templates for parts of apps, such as Razor Class Library, Razor Component, Razor Page, Web Config, etc. |
dotnet new [template name] |
Generates a new app from the chosen template. Note that the CLI will use the latest SDK installed to the local machine by default. The version can be signaled in the command line options, but it's not a simple numeric value. It may be more simple to generate the app and then modify the version in the app itself. Most likely on new generation the latest SDK would be used however. Note the name of the project is also not supplied. Create a folder and navigate to the folder root. This is unlike many other framework generators. |
dotnet restore |
Installs application's dependencies (similar to npm install ) |
dotnet add [package name] |
Installs dependency to the .csproj file which is a sort of combination of Application.cfc and packages.json
|
dotnet build |
Compiles the application — C# must be compiled |
dotnet run |
Runs the application — this will also build the app beforehand |
dotnet watch |
Similar to run but also watches the project for file changes — enables hot reloading |
dotnet tool install -g dotnet-ef |
Install Entity Framework globally |
Name | Description |
---|---|
ASP.NET Core | ⚪ Foundational for cross-platform web applications — can add optional UI and/or web service frameworks atop ⚪ Dependency injection, routing, authentication, caching, middleware, Razor templating, model binding, logging, Kestrel built-in web server ⚪ Kestrel similar to Tomcat with ColdFusion, to be placed behind a "real" web server like IIS (acting as reverse proxy), but used raw in development — created to fulfill cross-platform needs — using reverse proxy is popular because it allows multiple web servers and operating systems to run the same application |
Razor Pages | ⚪ UI/application framework ⚪ Server-side, page-based framework ⚪ Handles user interface features (the "view") ⚪ Similar to popular MVC and high-level SPA/SSG frameworks that use folder structure as a means of establishing routes ⚪ Built on top of ASP.NET Core/.NET platform ⚪ OnGet , OnPost , etc. handlers |
MVC | ⚪ UI/application framework ⚪ Follows Model-View-Controller pattern ⚪ Further abstraction, but similar to Razor Pages goal overall |
Blazor | ⚪ UI/application framework ⚪ Component-driven |
Web API | ⚪ Web service framework |
SignalR | ⚪ Web service framework |
GRPC | ⚪ Web service framework |
Entity Framework | ⚪ ORM |
Identity | ⚪ Authentication |
Name | Description |
---|---|
Razor | ⚪ Templating engine/syntax used in Razor Pages .cshtml views ⚪ Signaled around @ symbol ⚪ Designates beginning of C# expressions ⚪ Implicit expressions prefixed with @ ⚪ Explicit (more complicated) expressions in @( ... ) ⚪ Code blocks expressed with @{ ... } ⚪ Logic/flow marked with @if , @foreach , etc. ⚪ Special directives marked with @model , @layout , @using , @inject , etc. |
⚪ .NET applications have built-in middleware pipeline
⚪ Uses include HTTPS, static files, routing, etc.
⚪ Activated in Program.cs
and signaled by App.Use
⚪ Sequence or order does matter and can create a different outcome
⚪ Designed with performance in mind (will return request as soon as minimally possible, such as in the case of static files)
Name | Description |
---|---|
app.UseExceptionHandler() |
|
app.UseHttpsRedirection() |
|
app.UseStaticFiles() |
|
app.UseRouting() |
|
app.UseAuthorization() |
Name | Description |
---|---|
Visual Studio | Comes with Razor Pages and ASP.NET Core as part of the download (2022) |
VS Code | ⚪ Must install ASP.NET SDK separately ⚪ Will use .NET CLI ⚪ Need to install C# plug-in |
I am trying to catch up to the way solutions/projects have historically worked in the .NET world. Can you import more than once repo into a solution and share code this way? Sounds messy. Does this somehow explain the convention of the Shared
folder?
🔗 Consume ASP.NET Core Razor components from a Razor class library (RCL)
Create the component library:
dotnet new razorclasslib -o ComponentLibrary
Use it in another solution:
dotnet add reference {PATH TO LIBRARY}
- A "practice package" approach is to put binaries in a
lib
folder in your project until you're ready for packaging (I think would be managed through setting up references in Visual Studio?) Do you need to ask each teammate to set these up independently? I would at least think follow the same structure?
- When package creation is tied to the build, you can view it under
C:\Project\To\Path\bin\Debug
- Change
.nupkg
to.zip
to inspect the contents of the package
If you are using VSCode for at least parts of your workflow, you need to manage SDK installs on your machine. Supposedly you can install via command line using winget
. I tried twice and was unsuccessful with version 7. I needed to manually download the SDK and run the installer. In both cases, the installer GUI came up and indicated install progress. A key difference was that the manually installed workflow asked me to close running programs. Could this be the reason the winget
install needed to revert itself? Logs indicated MSI install failure.
-
Hardcoded Namespacing: I do not understand why app generation (via Visual Studio or CLI) results in so many hard-coded references to the project folder name and even project folder path. This makes it more difficult to move the project and I have broken projects by generating them and attempting to move them around. I do not see this in any other frameworks I've worked with. Is there a reason or is it possible to disable this behavior? It seems to be an attempt to intuit the project namespace.
-
Projects/Solutions Syntax Highlighting: If you generate a new app via CLI, it will not by default be a solution, which can cause some problems for Visual Studio. Problems I've noticed: shared corresponding files are not collapsed together, and the
@code
block in single file components does not get syntax highlighted.
Testing what this does?