Introduction
Learn how to read project properties stored in a C# project file.
By storing property values in the project file rather than in code or appsettings.json.
💡 No tampering once pushed to production.
Step 1
Add the following PropertyGroup to a .csproj file and replace values with your values.
<PropertyGroup> <Product> Code sample </Product> <Description> A sample project demonstrating assembly metadata retrieval. </Description> <Company> Payne services </Company> <Copyright> 2019-$([System.DateTime]::Now.Year) </Copyright> </PropertyGroup>
Enter fullscreen mode
Exit fullscreen mode
Step 2
Add the following project reference to the project Source code , which contains code to read values from the project file in step 1.
Step 3
Display values in an ASP.NET Core project.
Index.cshtml.cs
public class IndexModel ( ILogger < IndexModel > logger ) : PageModel { [ BindProperty ] public required Details Details { get ; set ; } private readonly ILogger < IndexModel > _logger = logger ;
public…