从VSTS部署网站至IIS后,部分文件未部署至目标路径的问题咨询
Hey there! Let’s sort out how to get all your website files deployed to C:\inetpub\wwwroot\TestVSTSWebsite properly. Based on your setup with TFS and Build/Release definitions, here are the key areas to check and fix:
1. Fix Your Build Definition’s Artifact Publishing
First, make sure your Build is actually packing all your files into the Artifact. Here’s what to verify:
- If you’re using the Visual Studio Build task: Add these MSBuild arguments to force full deployment packaging:
This ensures MSBuild copies every website-related file (static assets, configs, subfolders included) to the Artifact staging directory./p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PublishPath="$(build.artifactstagingdirectory)" - If you’re using a Copy Files task to create the Artifact:
- Set Source folder to your project’s root (or the folder containing all required files).
- Set Contents to
**/*—this wildcard includes every file and subfolder under the source path. - Double-check you haven’t added any exclusion patterns that might skip critical files.
2. Verify the Artifact Contains All Files
Before troubleshooting the Release, confirm your Build’s Artifact has everything you need. Go to your completed Build run in TFS, navigate to the Artifacts section, and view the contents. If files are missing here, the problem is in your Build setup—loop back to step 1 to adjust your tasks.
3. Update Your Release Definition’s Deployment Task
Once your Artifact is complete, make sure your Release is copying all files over correctly:
- If using IIS Web App Deploy:
- Ensure the Package or folder field points to the full Artifact path (e.g.,
$(System.DefaultWorkingDirectory)/**/drop). - Disable any file exclusion rules in the task settings that might filter out files you need.
- Ensure the Package or folder field points to the full Artifact path (e.g.,
- If using a Copy Files task for deployment:
- Set Source folder to the root of your Artifact (e.g.,
$(System.DefaultWorkingDirectory)/MyBuildDefinition/drop). - Set Contents to
**/*to include all files and subfolders. - Set Target folder to
C:\inetpub\wwwroot\TestVSTSWebsite. - Check the Overwrite existing files box to ensure new files replace old ones and no gaps are left.
- Set Source folder to the root of your Artifact (e.g.,
4. Check for Exclusion Rules in Your Project
Sometimes files get skipped due to project-level settings:
- Open your
.csprojfile and look for<ExcludeFilesFromDeployment>or<ExcludeFoldersFromDeployment>entries. If these exist, either remove them to deploy everything or adjust them to only exclude files you don’t need. - Double-check your
.tfignorefile—if it’s set to ignore certain files/folders, TFS won’t push them to the repo. Make sure any files you need deployed are not listed here (and have been committed to TFS already).
5. Confirm Deployment Permissions
Finally, ensure the account running your TFS deployment agent has full read/write access to C:\inetpub\wwwroot\TestVSTSWebsite. Permission issues often cause partial deployments (some files write successfully, others don’t). Test this by manually copying files to the target path using the agent’s account—if you hit access errors, adjust the folder permissions accordingly.
内容的提问来源于stack exchange,提问作者Shubham Khandelwal

