VSTS构建定义报错:解决方案文件含本地路径致目录不存在
Fixing Absolute Path Errors When Uploading .NET Websites to VSTS
Hey there, let's get this build error sorted out for you. The core issue here is that your solution file and project metadata are hardcoding your local PC's absolute path (inetpub/wwwroot/VSProjects), which doesn't exist on the VSTS build agent. Here's how to fix it quickly, plus the proper way to upload your project to avoid this in the future:
Quick Workaround for the Current Error
Edit the Solution File Locally
- Open your
.slnfile in a text editor (like Notepad++ or VS Code). - Look for any lines referencing your local absolute path (e.g., paths pointing to
inetpub/wwwroot/VSProjects). Replace these with relative paths based on your solution's folder structure. For example, if your website project lives in the same folder as the solution, just use the project name instead of the full local path.
- Open your
Check the .metaproj File
- Open the
PropertyRegister.metaprojfile mentioned in your error log. - Locate the
AspNetCompilertask line (visible in your build log:aspnet_compiler.exe -v /PropertyRegister -p ..\..\..\..\..\..\inetpub\wwwroot\VSProjects\PropertyRegister\ ...). - Replace the
-pparameter's absolute path with a relative path or build variable. For example, use$(SolutionDir)\PropertyRegister\(which points to the solution's root directory on the build agent) or a relative path like.\PropertyRegister\if the project is in the same folder as the metaproj.
- Open the
Commit and Push Changes
- Save the edited files, commit them to your local Git repo, and push the changes to VSTS. Re-run your build definition—this should resolve the missing directory error.
Proper Way to Upload .NET Websites to VSTS (Avoid Path Errors)
Follow these steps to ensure your project uses relative paths from the start:
Ensure Relative Paths in Local Project
- In Visual Studio, open your solution. Right-click the website project > Properties. Check all path-related settings (like "Web" tab configurations, project references, etc.) to confirm no local absolute paths are hardcoded. Visual Studio usually defaults to relative paths, but double-check to be safe.
Initialize Git in Your Solution Root
- Open Command Prompt or PowerShell, navigate to your solution's root folder (the one containing the
.slnfile). Run these commands:git init git add . git commit -m "Initial commit of .NET website project"
- Open Command Prompt or PowerShell, navigate to your solution's root folder (the one containing the
Push to VSTS Git Repository
- In VSTS, create a new Git repository for your project. Copy the repository's remote URL.
- Back in your local command line, run:
git remote add origin <your-VSTS-repo-URL> git push -u origin master
Configure a Correct Build Definition
- In VSTS, create a new build definition using the ASP.NET Web Application template (this template is optimized for .NET web projects and uses relative paths/build variables by default).
- If you use a custom build definition, ensure all build steps reference paths using VSTS predefined variables like
$(Build.SourcesDirectory)(which points to the agent's source code folder) instead of hardcoding paths.
Your Build Error Log for Reference
2018-01-19T16:34:14.3619604Z C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /PropertyRegister -p ..\..\..\..\..\..\inetpub\wwwroot\VSProjects\PropertyRegister\ -u -f PrecompiledWeb\PropertyRegister\ 2018-01-19T16:34:16.1411730Z ##[error]ASPNETCOMPILER(0,0): Error 1003: The directory 'd:\inetpub\wwwroot\VSProjects\PropertyRegister\' doesn't exist. 2018-01-19T16:34:16.1419278Z ASPNETCOMPILER : error 1003: The directory 'd:\inetpub\wwwroot\VSProjects\PropertyRegister\' doesn't exist. [d:\a\3\s\PropertyRegister\PropertyRegister.metaproj] 2018-01-19T16:34:16.1806460Z Done Building Project "d:\a\3\s\PropertyRegister\PropertyRegister.metaproj" (default targets) -- FAILED. 2018-01-19T16:34:16.1818301Z Done Building Project "d:\a\3\s\PropertyRegister\PropertyRegister.sln" (default targets) -- FAILED. 2018-01-19T16:34:16.1837158Z 2018-01-19T16:34:16.1837587Z Build FAILED. 2018-01-19T16:34:16.1873374Z 2018-01-19T16:34:16.1882800Z "d:\a\3\s\PropertyRegister\PropertyRegister.sln" (default target) (1) -> 2018-01-19T16:34:16.1884216Z (ValidateProjects target) -> 2018-01-19T16:34:16.1885795Z d:\a\3\s\PropertyRegister\PropertyRegister.sln.metaproj : warning MSB4121: The project configuration for project "PropertyRegister" was not specified in the solution file for the solution configuration "Release|Any CPU". [d:\a\3\s\PropertyRegister\PropertyRegister.sln]
内容的提问来源于stack exchange,提问作者Kieran
相关产品推荐
相关产品推荐

