webresources - phuocle/Dynamics-Crm-DevKit GitHub Wiki

CLI Task: webresources

URL: https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/cli/webresources

Overview

The webresources task uploads web resources (HTML, CSS, JavaScript, images, etc.) to Dynamics 365 / Dataverse.

Command Line Syntax

DynamicsCrm.DevKit.Cli.exe /conn:"YourConnectionString" /json:"DynamicsCrm.DevKit.Cli.json" /type:webresources /profile:"ProfileName"

Parameters

Required Parameters

Parameter Description Example
/conn Dynamics 365 connection string "/conn:AuthType=Office365;Url=https://yourorg.crm.dynamics.com;[email protected];Password=password"
/json Path to DynamicsCrm.DevKit.Cli.json file "/json:DynamicsCrm.DevKit.Cli.json"
/type Task type (must be "webresources") "/type:webresources"
/profile Profile name from json file "/profile:DEBUG"

Optional Parameters

Parameter Description Example
/sdklogin Use SDK login dialog "/sdklogin:yes"

JSON Configuration

Add a webresources section in your DynamicsCrm.DevKit.Cli.json:

{
  "webresources": [
    {
      "profile": "DEBUG",
      "solution": "YourSolution",
      "prefix": "new",
      "folder": "WebResources",
      "includefiles": [
"*.js",
        "*.html",
        "*.css",
        "*.png",
        "*.jpg",
        "*.gif",
     "*.ico",
   "*.xml",
        "*.xsl",
        "*.xslt",
     "*.svg"
    ],
      "excludefiles": [
        "*.map",
        "*.ts"
      ]
    }
  ]
}

JSON Properties

Property Type Required Description
profile string Yes Profile identifier
solution string Yes Target solution unique name
prefix string Yes Publisher prefix for web resource names
folder string Yes Source folder path containing web resources
includefiles array Yes File patterns to include
excludefiles array Yes File patterns to exclude

Supported Web Resource Types

Extension Web Resource Type Type Code
.html, .htm HTML 1
.css CSS 2
.js JavaScript 3
.xml XML 4
.png PNG Image 5
.jpg, .jpeg JPEG Image 6
.gif GIF Image 7
.xap Silverlight (XAP) 8
.xsl, .xslt XSL 9
.ico Icon 10
.svg SVG 11
.resx RESX 12

Web Resource Naming Convention

Web resources are automatically named following Dynamics 365 conventions:

{prefix}_{relativepath}_{filename}

Examples:

  • WebResources/scripts/account.form.js ? new_/scripts/account.form.js
  • WebResources/css/styles.css ? new_/css/styles.css
  • WebResources/images/logo.png ? new_/images/logo.png

Features

Smart Upload

  • Only uploads changed files (compares file content)
  • Creates new web resources automatically
  • Updates existing web resources
  • Preserves web resource metadata

Folder Structure Preservation

  • Maintains folder hierarchy in web resource names
  • Uses / as path separator in web resource names

Multi-Format Support

  • Scripts (JS)
  • Styles (CSS)
  • Pages (HTML)
  • Data (XML, RESX)
  • Images (PNG, JPG, GIF, SVG, ICO)

Examples

Example 1: Upload All Web Resources

DynamicsCrm.DevKit.Cli.exe ^
  /conn:"AuthType=Office365;Url=https://contoso.crm.dynamics.com;[email protected];Password=pass" ^
  /json:"DynamicsCrm.DevKit.Cli.json" ^
  /type:webresources ^
  /profile:"DEBUG"

Example 2: Upload Only JavaScript Files

{
  "webresources": [
    {
      "profile": "SCRIPTS",
      "solution": "MyProject",
      "prefix": "myproj",
      "folder": "WebResources",
      "includefiles": ["*.js"],
      "excludefiles": ["*.map", "*.min.js"]
    }
  ]
}

Example 3: Upload With SDK Login

DynamicsCrm.DevKit.Cli.exe ^
  /sdklogin:"yes" ^
  /json:"DynamicsCrm.DevKit.Cli.json" ^
  /type:webresources ^
  /profile:"DEBUG"

Example 4: Multiple Resource Types

{
  "webresources": [
    {
    "profile": "ALL",
   "solution": "MyProject",
  "prefix": "myproj",
      "folder": "WebResources",
      "includefiles": [
        "*.js",
  "*.html",
    "*.css",
        "*.png",
        "*.svg"
      ],
"excludefiles": [
        "*.map",
        "*.ts",
        "*.scss"
      ]
    }
  ]
}

Output

The task outputs:

  • ? CREATED - New web resources created
  • ? UPDATED - Existing web resources updated
  • ?? DO_NOTHING - No changes needed

Sample output:

| ? CREATED new_/scripts/account.form.js
| ? UPDATED new_/css/styles.css
| ?? DO_NOTHING new_/images/logo.png

Folder Structure Example

WebResources/
??? scripts/
?   ??? entities/
?   ?   ??? account.form.js
?   ?   ??? contact.form.js
?   ??? common/
?       ??? utilities.js
??? css/
?   ??? styles.css
??? images/
    ??? logo.png
??? icons/
        ??? custom.svg

Results in:

  • new_/scripts/entities/account.form.js
  • new_/scripts/entities/contact.form.js
  • new_/scripts/common/utilities.js
  • new_/css/styles.css
  • new_/images/logo.png
  • new_/images/icons/custom.svg

Publishing

Note: Web resources are uploaded but NOT automatically published. To publish:

  1. Manual Publishing: Use Dynamics 365 UI to publish web resources
  2. PowerShell: Use Publish-AllXml command
  3. SDK: Call PublishAllXml or PublishXml messages

Common Issues

Issue: Web resource not found after upload

Solution: Publish the web resources in Dynamics 365

Issue: File not uploading

Solution: Check file extension is in includefiles list and not in excludefiles

Issue: Wrong web resource name

Solution: Verify prefix matches your publisher prefix

Issue: Permission denied

Solution: Ensure user has privileges to create/update web resources

Best Practices

  1. Use descriptive prefixes that match your publisher prefix
  2. Organize files in logical folder structures
  3. Exclude source files like .ts, .scss, .map
  4. Version control your web resources
  5. Test locally before deploying
  6. Publish after upload to make changes visible

Performance Tips

  1. Use specific file patterns instead of uploading everything
  2. Separate profiles for different resource types
  3. Exclude build artifacts and source maps

Related Tasks

See Also

⚠️ **GitHub.com Fallback** ⚠️