MagicConstants 1.0.0-preview-01
See the version list below for details.
dotnet add package MagicConstants --version 1.0.0-preview-01
NuGet\Install-Package MagicConstants -Version 1.0.0-preview-01
<PackageReference Include="MagicConstants" Version="1.0.0-preview-01" />
paket add MagicConstants --version 1.0.0-preview-01
#r "nuget: MagicConstants, 1.0.0-preview-01"
// Install MagicConstants as a Cake Addin #addin nuget:?package=MagicConstants&version=1.0.0-preview-01&prerelease // Install MagicConstants as a Cake Tool #tool nuget:?package=MagicConstants&version=1.0.0-preview-01&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();
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 |