.sln 文件中的注释行
Comment lines in .sln file
我正在尝试临时注释 .sln 文件中的某些行,但收到错误消息:
"所选文件是解决方案文件,但似乎已损坏且无法打开"
根据 this blog 注释是由“#”完成的,但是当我注释掉 GlobalSection 中的每一行时(关于 Team Foundation Server 源代码控制绑定的部分)我得到以上错误。还有其他方法可以注释掉 .sln 中的行吗?
编辑 - 我想注释掉的部分:
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4BA58AB2-18FA-4D8F-95F4-32FFDF27D184C}
SccTeamFoundationServer = http://oxy:8080/tfs/projects
SccLocalPath0 = .
SccProjectUniqueName1 = Accounts\Accounts.vbproj
SccProjectName1 = Accounts
SccLocalPath1 = Accounts
EndGlobalSection
我试过了,但没有用:
# GlobalSection(TeamFoundationVersionControl) = preSolution
# SccNumberOfProjects = 2
# SccEnterpriseProvider = {4BA58AB2-18FA-4D8F-95F4-32FFDF27D184C}
# SccTeamFoundationServer = http://oxy:8080/tfs/projects
# SccLocalPath0 = .
# SccProjectUniqueName1 = Accounts\Accounts.vbproj
# SccProjectName1 = Accounts
# SccLocalPath1 = Accounts
# EndGlobalSection
P.S.: 我尝试使用“#”进行单行注释 - 行得通。并且删除整个部分也有效。但是我不想删除它,只是评论它。
我认为 .sln
文件中没有正式的评论定义。这取决于解析器.
原则上,.sln
文件是一个声明性文件,基于关键字(ProjectSection
、EndGlobalSection
)和结束行字符。我没有看到统一的格式描述。
MSBuild
所以我们不知道Visual Studio是如何读取.sln
文件的,但是你可以在msbuild code中看到任何一行不以 常量词之一开头的 将不会进入对象:
while ((str = ReadLine()) != null)
{
if (str.StartsWith("Project(", StringComparison.Ordinal))
{
ParseProject(str);
}
else if (str.StartsWith("GlobalSection(NestedProjects)", StringComparison.Ordinal))
{
ParseNestedProjects();
}
else if (str.StartsWith("GlobalSection(SolutionConfigurationPlatforms)", StringComparison.Ordinal))
{
ParseSolutionConfigurations();
}
else if (str.StartsWith("GlobalSection(ProjectConfigurationPlatforms)", StringComparison.Ordinal))
{
rawProjectConfigurationsEntries = ParseProjectConfigurations();
}
else if (str.StartsWith("VisualStudioVersion", StringComparison.Ordinal))
{
_currentVisualStudioVersion = ParseVisualStudioVersion(str);
}
else
{
// No other section types to process at this point, so just ignore the line
// and continue.
}
}
Visual Studio
According to this blog comments are done by "#"
这不准确。您可以在需要的地方添加 行 和 任何文本 ,没有 #
,文件将保持正确。
因此,在Visual Studio中,您目前还不知道官方格式,但您需要"break"当前格式。
您可以尝试更改关键字,例如在开头添加一个字母。
根据我的尝试,特殊字符(例如 #
、%
)不会破坏您的关键字。
我正在尝试临时注释 .sln 文件中的某些行,但收到错误消息: "所选文件是解决方案文件,但似乎已损坏且无法打开"
根据 this blog 注释是由“#”完成的,但是当我注释掉 GlobalSection 中的每一行时(关于 Team Foundation Server 源代码控制绑定的部分)我得到以上错误。还有其他方法可以注释掉 .sln 中的行吗?
编辑 - 我想注释掉的部分:
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4BA58AB2-18FA-4D8F-95F4-32FFDF27D184C}
SccTeamFoundationServer = http://oxy:8080/tfs/projects
SccLocalPath0 = .
SccProjectUniqueName1 = Accounts\Accounts.vbproj
SccProjectName1 = Accounts
SccLocalPath1 = Accounts
EndGlobalSection
我试过了,但没有用:
# GlobalSection(TeamFoundationVersionControl) = preSolution
# SccNumberOfProjects = 2
# SccEnterpriseProvider = {4BA58AB2-18FA-4D8F-95F4-32FFDF27D184C}
# SccTeamFoundationServer = http://oxy:8080/tfs/projects
# SccLocalPath0 = .
# SccProjectUniqueName1 = Accounts\Accounts.vbproj
# SccProjectName1 = Accounts
# SccLocalPath1 = Accounts
# EndGlobalSection
P.S.: 我尝试使用“#”进行单行注释 - 行得通。并且删除整个部分也有效。但是我不想删除它,只是评论它。
我认为 .sln
文件中没有正式的评论定义。这取决于解析器.
原则上,.sln
文件是一个声明性文件,基于关键字(ProjectSection
、EndGlobalSection
)和结束行字符。我没有看到统一的格式描述。
MSBuild
所以我们不知道Visual Studio是如何读取.sln
文件的,但是你可以在msbuild code中看到任何一行不以 常量词之一开头的 将不会进入对象:
while ((str = ReadLine()) != null)
{
if (str.StartsWith("Project(", StringComparison.Ordinal))
{
ParseProject(str);
}
else if (str.StartsWith("GlobalSection(NestedProjects)", StringComparison.Ordinal))
{
ParseNestedProjects();
}
else if (str.StartsWith("GlobalSection(SolutionConfigurationPlatforms)", StringComparison.Ordinal))
{
ParseSolutionConfigurations();
}
else if (str.StartsWith("GlobalSection(ProjectConfigurationPlatforms)", StringComparison.Ordinal))
{
rawProjectConfigurationsEntries = ParseProjectConfigurations();
}
else if (str.StartsWith("VisualStudioVersion", StringComparison.Ordinal))
{
_currentVisualStudioVersion = ParseVisualStudioVersion(str);
}
else
{
// No other section types to process at this point, so just ignore the line
// and continue.
}
}
Visual Studio
According to this blog comments are done by "#"
这不准确。您可以在需要的地方添加 行 和 任何文本 ,没有 #
,文件将保持正确。
因此,在Visual Studio中,您目前还不知道官方格式,但您需要"break"当前格式。
您可以尝试更改关键字,例如在开头添加一个字母。
根据我的尝试,特殊字符(例如 #
、%
)不会破坏您的关键字。