Automated SharePoint Framework project setup with Azure DevOps package feed integration.
Automates the complete SPFx development environment setup:
- β Creates new SPFx project using Yeoman generator
- β Configures Azure DevOps Artifacts package feed
- β Installs all dependencies
- β Sets up spfx-fast-serve for rapid development
- β Generates launch scripts and documentation
- β Configures secure .npmrc with PAT authentication
Install these before running the script:
- Node.js v18.x - Download
- npm (comes with Node.js)
- PowerShell (built into Windows)
- Download both files:
RUN-SETUP.batSPFx-Azure-Setup.ps1
- Put them in the same folder
- Double-click
RUN-SETUP.bat - Answer the prompts
# Navigate to script directory
cd C:\Path\To\Scripts
# Run the script
.\SPFx-Azure-Setup.ps1The script will prompt you for:
- Project Name - e.g.,
MyCustomWebPart - SharePoint URL - e.g.,
https://veritas.sharepoint.com(default) - Site Name - e.g.,
dev(for testing) - Azure DevOps Organization - e.g.,
mycompany - Azure DevOps Project ID - GUID from your Azure DevOps project
- Package Feed Name - e.g.,
shared-packages - Package Scope - e.g.,
@mycompany - Personal Access Token (PAT) - from Azure DevOps
Then the Yeoman SPFx generator will ask:
- Framework choice (React, etc.)
- Web part name
- Description
Your Azure DevOps URL: https://dev.azure.com/{ORGANIZATION}/
- Go to your Azure DevOps project
- Click "Project Settings" (bottom left)
- Look at the URL:
https://dev.azure.com/{org}/_settings/projects?id={PROJECT-ID} - Copy the GUID after
id=
- Go to "Artifacts" in Azure DevOps
- Your feed name is shown at the top
- Click your profile icon β "Personal access tokens"
- Click "New Token"
- Give it a name (e.g., "SPFx Development")
- Set expiration (recommend 90 days)
- Scopes: Check "Packaging (Read)"
- Copy the token (you won't see it again!)
C:\SPFx\YourProject\
βββ .npmrc # Azure DevOps credentials (DO NOT COMMIT)
βββ .gitignore # Prevents .npmrc from being committed
βββ README.md # Project documentation
βββ START-DEV-SERVER.ps1 # Quick launcher script
βββ src/ # Your source code
βββ config/ # SPFx configuration
βββ node_modules/ # Dependencies
βββ package.json # Project manifest
cd C:\SPFx\YourProject
npm run serveOr double-click START-DEV-SERVER.ps1
-
First Tab - Trust SSL certificate:
https://localhost:4321/temp/manifests.jsAccept the warning, keep tab open
-
Second Tab - Open workbench:
https://veritas.sharepoint.com/sites/{yoursite}/_layouts/15/workbench.aspx?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js
After setup, you can install packages from your Azure DevOps feed:
npm install @mycompany/shared-libraryThe .npmrc file contains your Personal Access Token in plain text.
DO NOT:
- Commit
.npmrcto source control - Share
.npmrcwith others - Email or message the file
- Store it in cloud sync folders (Dropbox, OneDrive)
DO:
- Keep
.npmrconly in your local project - Use
.gitignoreto exclude it (script creates this) - Set PAT expiration dates
- Rotate tokens regularly
The script creates a .gitignore file that includes:
.npmrc
Always verify before committing:
git status
# .npmrc should NOT appear in the list# Clean
gulp clean
# Build for production
gulp build --ship
gulp bundle --ship
gulp package-solution --shipPackage location: sharepoint/solution/*.sppkg
- Upload
.sppkgto App Catalog - Click "Deploy"
- Trust the solution
- Add to site collection
# Open PowerShell as Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser# Clear npm cache
npm cache clean --force
# Delete node_modules and retry
rm -r node_modules
npm installCheck:
- PAT token is valid (not expired)
- Token has "Packaging (Read)" permission
- Organization name is correct
- Project ID is correct (GUID format)
- Feed name is correct
Regenerate token in Azure DevOps if needed.
gulp clean
npm run serveThis is normal for local development:
- Visit
https://localhost:4321/temp/manifests.js - Click "Advanced" β "Proceed to localhost"
- Keep this tab open while developing
Feel free to submit issues and enhancement requests!
MIT License - feel free to use and modify
Example Configuration:
- SharePoint:
https://veritas.sharepoint.com - Azure DevOps:
https://dev.azure.com/mycompany - Package Feed:
shared-packages - Package Scope:
@mycompany