webresources - phuocle/Dynamics-Crm-DevKit GitHub Wiki
URL: https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/cli/webresources
The webresources task uploads web resources (HTML, CSS, JavaScript, images, etc.) to Dynamics 365 / Dataverse.
DynamicsCrm.DevKit.Cli.exe /conn:"YourConnectionString" /json:"DynamicsCrm.DevKit.Cli.json" /type:webresources /profile:"ProfileName"| 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" |
| Parameter | Description | Example |
|---|---|---|
/sdklogin |
Use SDK login dialog | "/sdklogin:yes" |
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"
]
}
]
}| 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 |
| 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 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
- Only uploads changed files (compares file content)
- Creates new web resources automatically
- Updates existing web resources
- Preserves web resource metadata
- Maintains folder hierarchy in web resource names
- Uses
/as path separator in web resource names
- Scripts (JS)
- Styles (CSS)
- Pages (HTML)
- Data (XML, RESX)
- Images (PNG, JPG, GIF, SVG, ICO)
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"{
"webresources": [
{
"profile": "SCRIPTS",
"solution": "MyProject",
"prefix": "myproj",
"folder": "WebResources",
"includefiles": ["*.js"],
"excludefiles": ["*.map", "*.min.js"]
}
]
}DynamicsCrm.DevKit.Cli.exe ^
/sdklogin:"yes" ^
/json:"DynamicsCrm.DevKit.Cli.json" ^
/type:webresources ^
/profile:"DEBUG"{
"webresources": [
{
"profile": "ALL",
"solution": "MyProject",
"prefix": "myproj",
"folder": "WebResources",
"includefiles": [
"*.js",
"*.html",
"*.css",
"*.png",
"*.svg"
],
"excludefiles": [
"*.map",
"*.ts",
"*.scss"
]
}
]
}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
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.jsnew_/scripts/entities/contact.form.jsnew_/scripts/common/utilities.jsnew_/css/styles.cssnew_/images/logo.pngnew_/images/icons/custom.svg
Note: Web resources are uploaded but NOT automatically published. To publish:
- Manual Publishing: Use Dynamics 365 UI to publish web resources
- PowerShell: Use Publish-AllXml command
- SDK: Call PublishAllXml or PublishXml messages
Solution: Publish the web resources in Dynamics 365
Solution: Check file extension is in includefiles list and not in excludefiles
Solution: Verify prefix matches your publisher prefix
Solution: Ensure user has privileges to create/update web resources
- Use descriptive prefixes that match your publisher prefix
- Organize files in logical folder structures
-
Exclude source files like
.ts,.scss,.map - Version control your web resources
- Test locally before deploying
- Publish after upload to make changes visible
- Use specific file patterns instead of uploading everything
- Separate profiles for different resource types
- Exclude build artifacts and source maps
- downloadwebresources - Download web resources from Dynamics 365