XrmTools.WebResources.Sdk
1.2.0
<Sdk Name="XrmTools.WebResources.Sdk" Version="1.2.0" />
#:sdk XrmTools.WebResources.Sdk@1.2.0
XrmTools.WebResources.Sdk is an MSBuild project SDK that lets you build Power Platform (Dataverse) TypeScript/JavaScript web resources as part of your regular build. It wraps your npm-based web resource project so it restores, builds, and cleans through standard MSBuild and Visual Studio commands, and integrates cleanly with the Power Platform Solution Packager.
This package is part of the Xrm Tools extension for Visual Studio, which provides a set of tools to enhance your development experience with Microsoft Dataverse (formerly known as Common Data Service or Dynamics 365).
If you aren't already using Xrm Tools for Power Platform development, check out the Xrm Tools Wiki to learn how a modern approach to Power Platform development can enhance your experience.
Usage
Reference the SDK from your web resource project file:
<Project Sdk="XrmTools.WebResources.Sdk/1.2.0">
</Project>
Your project directory must contain a package.json. The SDK invokes the following npm scripts during the corresponding MSBuild targets:
| MSBuild target | Default command |
|---|---|
| Restore | npm install (local) / npm ci (CI) |
| Build (Debug) | npm run build:debug |
| Build (Release) | npm run build:release |
| Clean | npm run clean |
Restore behavior
Build automatically runs Restore first. For local development Restore runs npm install, so the
first build works without a separate terminal step. Restore is incremental: subsequent builds skip
npm install until package.json or package-lock.json changes, or until node_modules is deleted.
Adding, updating, or removing a dependency is therefore picked up automatically on the next build.
In a build pipeline the SDK switches to npm ci for a clean, reproducible install, but only when a committed package-lock.json is present (it is required by npm ci). A build is treated as CI when any of ContinuousIntegrationBuild, CI, TF_BUILD, or GITHUB_ACTIONS is true. If no lock file exists, it falls back to npm install.
You can force either behavior explicitly with NpmRestoreCommand (see below), or set IsCiBuild yourself.
Customization
You can override any of the default commands or the output folder via MSBuild properties in your project:
<PropertyGroup>
<NpmRestoreCommand>npm install</NpmRestoreCommand>
<NpmBuildCommand>npm run build</NpmBuildCommand>
<NpmCleanCommand>npm run clean</NpmCleanCommand>
<BuildOutputFolder>$(MSBuildProjectDirectory)\dist</BuildOutputFolder>
</PropertyGroup>
Dataverse registration
Xrm Tools can register all supported files produced by the project. Configure the unmanaged solution and the logical-name prefix in the project file:
<PropertyGroup>
<DataverseSolutionUniqueName>ContosoSolution</DataverseSolutionUniqueName>
<WebResourceNamePrefix>contoso_/scripts/Contoso.</WebResourceNamePrefix>
</PropertyGroup>
The prefix is also the ownership boundary used when reconciling resources removed from the
project. Output paths below BuildOutputFolder are appended to the prefix and normalized to /.
Individual resources can override their registration metadata:
<ItemGroup>
<WebResource Update="$(BuildOutputFolder)\app.js"
Name="contoso_/scripts/application.js"
DisplayName="Application script" />
</ItemGroup>
For example, to always use a reproducible install, pin the command regardless of environment:
<PropertyGroup>
<NpmRestoreCommand>npm ci</NpmRestoreCommand>
</PropertyGroup>
To learn more about the Xrm Tools extension for Visual Studio, please refer to:
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.