惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
Jina AI
Jina AI
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
小众软件
小众软件
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
月光博客
月光博客
L
LangChain Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
C
Check Point Blog
U
Unit 42
人人都是产品经理
人人都是产品经理

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Display project Attribute (C#)
Karen Payne · 2026-04-27 · via DEV Community

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.

Shows values on index page

Index.cshtml.cs

public class IndexModel(ILogger<IndexModel> logger) : PageModel
{
    [BindProperty]
    public required Details Details { get; set; }
    private readonly ILogger<IndexModel> _logger = logger;

    public void OnGet()
    {
        Details = GetAllInfo();
    }

    Details GetAllInfo() =>
        new()
        {
            Company = Info.GetCompany(),
            Copyright = Info.GetCopyright(),
            Product = Info.GetProduct(),
            Description = Info.GetDescription(),
            Version = Info.GetVersion().ToString()
        };
}

Enter fullscreen mode Exit fullscreen mode

Index.cshtml (using Bootstrap 5x)

@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}
<style>
    .table tr > td:first-child {
        font-weight: bold;
        text-align: right;
    }
    H1 {
        margin-bottom: 1em;
    }
</style>

<div class="container">
    <main>
        <h1 class="fs-3">Code sample</h1>
        <table class="table table-striped table-borderless">
            <tr>
                <td>Product</td>
                <td>@Model.Details.Product</td>
            </tr>
            <tr>
                <td>Version</td>
                <td>@Model.Details.Version</td>
            </tr>
            <tr>
                <td>Copyright</td>
                <td>@Model.Details.Copyright</td>
            </tr>
            <tr>
                <td>Company</td>
                <td>@Model.Details.Company</td>
            </tr>
            <tr>
                <td>Description</td>
                <td>@Model.Details.Description</td>
            </tr>
        </table>
    </main>
</div>

Enter fullscreen mode Exit fullscreen mode

Display values in a Console Core project.

  • Uses the same class project as used in the ASP.NET Core project
  • The following method gets the values to display using NuGet package Spectre.Console.

Display values in a console app window

internal static void ShowDetails()
{
    var table = new Table()
        .RoundedBorder()
        .BorderColor(Color.Pink1)
        .Title("[yellow bold]Information[/]");

    table.AddColumn("[yellow bold]Attribute[/]");
    table.AddColumn("[yellow bold]Value[/]");

    var details = GetAllInfo();
    table.AddRow("[cyan]Product[/]", details.Product);
    table.AddRow("[cyan]Version[/]", details.Version);
    table.AddRow("[cyan]Copyright[/]", details.Copyright);
    table.AddRow("[cyan]Company[/]", details.Company);
    table.AddRow("[cyan]Description[/]", details.Description);
    AnsiConsole.Write(table);


    Details GetAllInfo()
    {
        return new Details()
        {
            Company = Info.GetCompany(),
            Copyright = Info.GetCopyright(),
            Product = Info.GetProduct(),
            Description = Info.GetDescription(),
            Version = Info.GetVersion().ToString()
        };
    }
}

Enter fullscreen mode Exit fullscreen mode

Display code.

internal partial class Program
{
    static void Main(string[] args)
    {

        ShowDetails();

        SpectreConsoleHelpers.ExitPrompt(Justify.Left);
    }
}

Enter fullscreen mode Exit fullscreen mode

.NET 9 Core source

Core class project

ASP.NET Core project

Console project