MagicConstants 1.0.0-preview-02

This is a prerelease version of MagicConstants.
dotnet add package MagicConstants --version 1.0.0-preview-02                
NuGet\Install-Package MagicConstants -Version 1.0.0-preview-02                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MagicConstants" Version="1.0.0-preview-02" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MagicConstants --version 1.0.0-preview-02                
#r "nuget: MagicConstants, 1.0.0-preview-02"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MagicConstants as a Cake Addin
#addin nuget:?package=MagicConstants&version=1.0.0-preview-02&prerelease

// Install MagicConstants as a Cake Tool
#tool nuget:?package=MagicConstants&version=1.0.0-preview-02&prerelease                

Magic Constants

Magic Constants is a dotnet source generator that generates C# constants from files in your project. It can also minify files and set cache control headers for routes.

This is especially useful for web projects where you want to reference files in your code without hardcoding the paths nor having to manage the string constants.

Global settings in your project:

<PropertyGroup>
  <MagicConstantsVisibility>public</MagicConstantsVisibility>
  <MagicConstantsRoutes>true</MagicConstantsRoutes>
  <MagicConstantsRoutesCacheControl>public, max-age=604800</MagicConstantsRoutesCacheControl>
  <MagicConstantsMinify>true</MagicConstantsMinify>
</PropertyGroup>

Specific settings ( Note: if not specified, global settings will be used instead )

<ItemGroup>
  <AdditionalFiles Include="**\*.html" MagicClass="Pages" MagicRemoveRouteExtension="true" MagicCacheControl="public, max-age=86400" MagicMinify="true" />
  <AdditionalFiles Include="**\*.css" MagicClass="Assets" MagicMinify="true" />
  <AdditionalFiles Include="**\*.js" MagicClass="Assets" MagicMinify="true" />
  <AdditionalFiles Include="**\*.svg" MagicClass="Images" />
  <AdditionalFiles Include="**\*.png" MagicClass="Images" />
  <AdditionalFiles Include="**\*.ico" MagicClass="Images" />
</ItemGroup>

When MagicConstantsRoutes is enabled, it will generate an aspnet route for every file. All you have to do, is call the mapping method:

app.MapViews();
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview-02 50 12/11/2024
1.0.0-preview-01 42 12/11/2024