Scarlet.Sass.MSBuild 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Scarlet.Sass.MSBuild --version 1.0.0
                    
NuGet\Install-Package Scarlet.Sass.MSBuild -Version 1.0.0
                    
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="Scarlet.Sass.MSBuild" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Scarlet.Sass.MSBuild" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Scarlet.Sass.MSBuild">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Scarlet.Sass.MSBuild --version 1.0.0
                    
#r "nuget: Scarlet.Sass.MSBuild, 1.0.0"
                    
#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.
#:package Scarlet.Sass.MSBuild@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Scarlet.Sass.MSBuild&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Scarlet.Sass.MSBuild&version=1.0.0
                    
Install as a Cake Tool

Scarlet.Sass.MSBuild

Compile Dart Sass before ASP.NET Core, Blazor, and Razor Class Library static web assets are discovered.

Scarlet.Sass.MSBuild is intentionally explicit: it compiles only @(SassBeforeStaticWebAssets) items. There is no automatic Sass/ convention and no sasscompiler.json or appsettings.json configuration dialect.

Install

dotnet add package Scarlet.Sass.MSBuild
dotnet add package Scarlet.Sass.Runtime.windows-x64

Use the runtime package that matches the build host:

  • Scarlet.Sass.Runtime.windows-x64
  • Scarlet.Sass.Runtime.windows-arm64
  • Scarlet.Sass.Runtime.linux-x64
  • Scarlet.Sass.Runtime.linux-arm64
  • Scarlet.Sass.Runtime.linux-x64-musl
  • Scarlet.Sass.Runtime.linux-arm64-musl
  • Scarlet.Sass.Runtime.darwin-x64
  • Scarlet.Sass.Runtime.darwin-arm64

Or let the build download Dart Sass:

<PropertyGroup>
  <SassRuntimeDownload>true</SassRuntimeDownload>
  <SassVersionDownload>1.104.1</SassVersionDownload>
  <SassRuntimeDirectory>$(MSBuildProjectDirectory)\.sass</SassRuntimeDirectory>
</PropertyGroup>

Compile Before Static Web Assets

Directory-to-directory:

<ItemGroup>
  <SassBeforeStaticWebAssets Include="Sass">
    <OutputPath>wwwroot/css</OutputPath>
    <OutputStyle>Compressed</OutputStyle>
  </SassBeforeStaticWebAssets>
</ItemGroup>

File-to-file:

<ItemGroup>
  <SassBeforeStaticWebAssets Include="Sass/site.scss">
    <OutputPath>wwwroot/css/site.css</OutputPath>
  </SassBeforeStaticWebAssets>
</ItemGroup>

Sass partials whose file name starts with _ are not entry points. They can still be imported or used by other Sass files.

Properties

Property Default Meaning
SassEnabled true Enables RunSassBeforeStaticWebAssets.
SassOutputStyle Auto Auto, Expanded, or Compressed. Auto is expanded for Debug and compressed otherwise.
SassSourceMap Auto Auto, true, or false.
SassEmbedSources Auto Auto, true, or false.
SassQuietDeps false Adds --quiet-deps.
SassLoadPaths empty Semicolon-separated load paths passed as --load-path.
SassPkgImporter empty Set to node to pass --pkg-importer=node.
SassSilenceDeprecations empty Semicolon-separated values for --silence-deprecation.
SassFatalDeprecations empty Semicolon-separated values for --fatal-deprecation.
SassAdditionalArguments empty Extra raw Dart Sass arguments.
SassRuntimeDirectory empty Explicit runtime directory containing <rid>/native/dart-sass/<sass launcher>.
SassRuntimeDownload false Download the runtime instead of using runtime packages.
SassVersionDownload empty Version to download. Empty means the pinned package version.
SassDownloadMutexTimeoutSeconds 300 Timeout for concurrent download coordination.
SassStampDirectory $(IntermediateOutputPath)\Scarlet.Sass Settings stamp and generated-file manifest directory.
SassTimeoutMilliseconds 0 Maximum time to wait for each Dart Sass invocation before killing it. 0 waits indefinitely.

Item Metadata

SassBeforeStaticWebAssets supports the same compile metadata as the global properties:

<SassBeforeStaticWebAssets Include="Sass">
  <OutputPath>wwwroot/css</OutputPath>
  <OutputStyle>Compressed</OutputStyle>
  <SourceMap>true</SourceMap>
  <EmbedSources>false</EmbedSources>
  <QuietDeps>true</QuietDeps>
  <LoadPaths>node_modules;shared/styles</LoadPaths>
  <PkgImporter>node</PkgImporter>
  <SilenceDeprecations>import;global-builtin</SilenceDeprecations>
  <FatalDeprecations>color-functions</FatalDeprecations>
  <AdditionalArguments>--charset</AdditionalArguments>
</SassBeforeStaticWebAssets>

OutputPath is required. If the item points at a directory, OutputPath must be a directory. If the item points at a file, OutputPath can be a .css file or a path whose extension will be changed to .css.

Incrementality

Scarlet.Sass invokes Dart Sass with --update, so Dart Sass owns Sass dependency freshness. Scarlet owns the MSBuild side:

  • settings/runtime stamps
  • generated-file manifests
  • stale output deletion
  • dotnet clean cleanup
  • static web asset @(Content) and @(FileWrites) injection

If settings or runtime selection changes, expected CSS and map outputs are deleted before Dart Sass runs so --update cannot incorrectly skip them.

Embedded Sass Protocol

The Embedded Sass Protocol is valuable for a long-lived compiler host that reuses a process across many compilations. Scarlet.Sass.MSBuild v1 uses the Dart Sass CLI instead. The package is scoped around build integration and static web assets, and the CLI keeps the implementation simpler while preserving a path to add another engine later if benchmarks justify it.

CSS Isolation

CSS isolation integration is intentionally deferred. v1 focuses on project/RCL static web asset generation through explicit SassBeforeStaticWebAssets items.

License

Scarlet.Sass is MIT licensed. Dart Sass is distributed under its own MIT license; see LICENSE-3RD-PARTY.txt in the package.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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.1.0 176 9/27/2026
1.0.0 106 9/24/2026