Visual Studio和项目引用的最大路径长度

时间:2022-09-10 22:20:30

We have a number of projects, and each lives deep in a folder structure. When one set of projects needs to reference a project in a different folder, the reference can fail because the relative path to is in VS is too long.

我们有许多项目,每个项目都深入文件夹结构。当一组项目需要引用不同文件夹中的项目时,引用可能会失败,因为VS中的相对路径太长。

For example, project 1 will be in:

例如,项目1将位于:

C:\folderA\folder1\folder2...\folderN\myProject1.csproj

It references another project:

它引用了另一个项目:

C:\folderB\folder1\folder2...\folderN\myProject2.csproj

The HintPath to the reference is stored as a relative path, as in ............\folderB\folder1\folder2...\folderN\myProject2.csproj

引用的HintPath存储为相对路径,如............ \ folderB \ folder1 \ folder2 ... \ folderN \ myProject2.csproj

When VS loads the solution, it can't resolve the reference because the absolute path it builds includes numerous ../'s such that the path exceeds 256 characters. And the build fails.

当VS加载解决方案时,它无法解析引用,因为它构建的绝对路径包含许多../,因此路径超过256个字符。构建失败了。

We fix it by editing the csproj and putting in an absolute path, which is just silly.

我们通过编辑csproj并输入绝对路径来修复它,这很愚蠢。

What is the best solution for this?

什么是最好的解决方案?

2 个解决方案

#1


3  

Short answer - don't do that and it will not hurt. Consider less deep hierarchies and make related projects to live close.

简短的回答 - 不要这样做,也不会受到伤害。考虑不太深层次的层次结构,并使相关项目密切合作。

MSBuild is managed application and CLR have restriction on path/file name length of about 256 characters...

MSBuild是托管应用程序,CLR对路径/文件名长度限制约256个字符...

#2


2  

The max recommended project name length is 64 char. Team foundation server do not allow more than 64 char See the following link http://www.grabthecode.com/visual-studio/length-of-visual-studio-project-name

建议的最大项目名称长度为64个字符。团队基础服务器不允许超过64个字符请参阅以下链接http://www.grabthecode.com/visual-studio/length-of-visual-studio-project-name

#1


3  

Short answer - don't do that and it will not hurt. Consider less deep hierarchies and make related projects to live close.

简短的回答 - 不要这样做,也不会受到伤害。考虑不太深层次的层次结构,并使相关项目密切合作。

MSBuild is managed application and CLR have restriction on path/file name length of about 256 characters...

MSBuild是托管应用程序,CLR对路径/文件名长度限制约256个字符...

#2


2  

The max recommended project name length is 64 char. Team foundation server do not allow more than 64 char See the following link http://www.grabthecode.com/visual-studio/length-of-visual-studio-project-name

建议的最大项目名称长度为64个字符。团队基础服务器不允许超过64个字符请参阅以下链接http://www.grabthecode.com/visual-studio/length-of-visual-studio-project-name