Component | Build | Status |
---|---|---|
ASP.NET Core ODataDotNetTemplate | Rolling | |
ASP.NET Core ODataDotNetTemplate | Nightly |
This repository provides a .NET template for creating an ASP.NET Core Web API project with OData support. It supports configurations for .NET 8.0 and above, with appropriate setups for each version.
- Download and install .NET
- Visual Studio IDE - optional
- VS Code - optional
Follow these steps to use the template locally:
git clone https://github.com/OData/AspNetCoreODataDotNetTemplate.git
This project uses MSBuild to automate the build process and generate content from templates. Below are key files involved in this process.
- Directory.Build.targets:
tools/Directory.Build.targets
contains custom MSBuild targets applied to all projects in the directory and its subdirectories. Also contains targets for managing version information. - Directory.Build.props:
Directory.Build.props
contains common properties applied to all projects in the directory and its subdirectories.
Navigate to the cloned repository directory and build the project to restore necessary packages and dependencies:
cd <repository-directory>/AspNetCoreODataDotNetTemplate/sln
dotnet build
At the root, there is a PowerShell script (build.ps1
) that automates building, creating NuGet packages, and testing the AspNetCoreOData template project.
To run the script, open a PowerShell terminal, navigate to the directory containing the build.cmd
file, and execute the script with the -help
parameter:
build.cmd -help
- Build the solution with default settings:
.\build.cmd
- Build the solution in Debug configuration and run tests with detailed verbosity:
.\build.cmd -SolutionPath ".\sln\MySolution.sln" -c "Debug" -Test -v "Detailed"
- Build the solution and create NuGet packages:
.\build.cmd -SolutionPath ".\sln\MySolution.sln"
- Running tests:
.\build.cmd -Test
Building this repo produces artifacts in the following structure:
artifacts/
bin/ = Compiled binaries and executables
obj/ = Intermediate object files and build logs
log/
*.log = Log files for test runs and individual tests
$(Configuration)/
*.binlog = Binary logs for most build phases
packages/
$(Configuration)/
*.nupkg = NuGet packages for nuget.org
This script increments the version number in the specified msbuild props file. The version number can be incremented in the following ways:
- Major version increment
- Minor version increment
- Revision version increment
- Version release number increment
versionPath
: The path to the msbuild props file where the version number is specified.lastReleaseCommit
: The ID of the last commit to be released.forceMajorIncrement
: Whether to force an increment of the major version number.versionRelease
: The version number to be released. For example, preview, beta, alpha, etc.forceMinorIncrement
: Whether to force an increment of the minor version number.Help
: Show help.
Increment the minor version number in the Directory.Build.targets
file:
The generated project will have the following structure:
ODataWebApiApplication/
├── Controllers/
│ └── CustomersController.cs
├── Models/
│ └── Customer.cs
│ └── Order.cs
├── Properties/
│ └── launchSettings.json
├── EdmModelBuilder.cs
├── ODataWebApiApplication.csproj
├── ODataWebApiApplication.http
├── Program.cs
└── appsettings.Development.json
└── appsettings.json
This project has adopted the .NET Foundation Contributor Covenant Code of Conduct. For more information see the Code of Conduct FAQ.
This project is supported by the .NET Foundation.
ODataDotNetTemplate is a Copyright of © .NET Foundation and other contributors. It is licensed under MIT License