VS2013 解決方案檔案結構分析

2021-09-06 20:53:47 字數 3926 閱讀 4623

visual studio 的解決方案檔案是乙個文字檔案,其中的內容不是太複雜,有些時候 visual studio 會把這個檔案搞亂,理解一下這個檔案的結構,對我們處理一些異常情況有所幫助。

# 表示注釋行

microsoft visual studio solution file:用來說明解決方案檔案的版本號,12.00 說明是 vs2013 的解決方案檔案。

visualstudioversion:開啟這個解決方案檔案需要的 visual studio 版本號

minimumvisualstudioversion:能夠開啟這個解決方案的最低 visual studio 版本號。

下面是乙個解決方案檔案的示例。

microsoft visual studio solution file, format version 12.00

# visual studio 2013

visualstudioversion = 12.0.31101.0

minimumvisualstudioversion = 10.0.40219.1

解決方案中包含若干個專案,每個專案有乙個 project 的說明。

project( 專案在解決方案中的編號=顯示名稱, 實際路徑, 專案唯一標識  )

endproject

<

projectguid

>

projectguid

>

如果是解決方案資料夾, 則實際路徑與顯示名稱一致。

比如,在解決方案中建立了乙個名為 newfolder1 的解決方案資料夾。

在解決方案檔案中就會多出來乙個特殊的 project。

project("") = "newfolder1", 

"newfolder1",

""endproject

所以,我們可以理解為什麼解決方案資料夾不能巢狀了。

如果我們在解決方案資料夾中建立了乙個專案。

專案的說明示例如下。

project("") = "classlibrary1", 

"newfolder1\classlibrary1\classlibrary1.csproj",

""endproject

那麼,在解決方案檔案中中的 global 節中,會多出來乙個 globalsection(nestedprojects) = presolution

globalsection(nestedprojects) = presolution

= endglobalsection

你會看到前面是專案的標識,等號的後面就是解決方案資料夾的標識。這個巢狀的 nestedprojects 用來說明使用解決方案資料夾組織的專案。

在所有 project 說明之後,應該存在乙個 global 配置節

global

globalsection(solutionconfigurationplatforms) = presolution

debug|any cpu = debug|any cpu

release|any cpu = release|any cpu

endglobalsection

globalsection(projectconfigurationplatforms) = postsolution

.debug|any cpu.activecfg = debug|any cpu

.debug|any cpu.build.0 = debug|any cpu

.release|any cpu.activecfg = release|any cpu

.release|any cpu.build.0 = release|any cpu

endglobalsection

globalsection(solutionproperties) = presolution

hidesolutionnode = false

endglobalsection

endglobal

可以看到有三個部分組成

整個解決方案的配置資訊在 solutionconfigurationplatforms 中。

globalsection(solutionconfigurationplatforms) = presolution

debug|any cpu = debug|any cpu

release|any cpu = release|any cpu

endglobalsection

每個專案的平台配置資訊在 projectconfigurationplatforms 中。

globalsection(projectconfigurationplatforms) = postsolution

.debug|any cpu.activecfg = debug|any cpu

.debug|any cpu.build.0 = debug|any cpu

.release|any cpu.activecfg = release|any cpu

.release|any cpu.build.0 = release|any cpu

endglobalsection

專案的屬性。

globalsection(solutionproperties) = presolution

hidesolutionnode = false

endglobalsection

如果使用 tfs 來管理專案,在 global 配置節中會多出來乙個 globalsection(teamfoundationversioncontrol) = presolution 的配置節。

需要注意的是,這個多出來的配置節只能有乙個,有的時候 tfs 會錯誤的多新增若干個,這時候,在開啟專案的時候,你應該會看到如下的提示資訊。

注意解決方案中實際包含的專案數量,多出來的 teamfoundationversioncontrol 配置節中專案數量一般不對。一般來說,保留第乙個,將其他的刪除就可以了。

下面是乙個配置節的示例。

globalsection(teamfoundationversioncontrol) = presolution

sccnumberofprojects = 25

sccenterpriseprovider =

sccteamfoundationserver =

scclocalpath0 = .

sccprojectuniquename1 = ***\\yyy\\zzz.csproj

sccprojecttoplevelparentuniquename1 = ttt.sln

sccprojectname1 = ***/yyy

scclocalpath1 = ***\\yyy

endglobalsection

其中scclocalpath0:源**管理器的本地目錄

具體解決方案中的專案再分別列出來,每個專案佔 4 行。

sccprojectuniquename1:專案的路徑

sccprojecttoplevelparentuniquename1:就是解決方案的名稱

sccprojectname1:專案的名稱,注意已經包含了專案資料夾字首

scclocalpath1:儲存在本地的專案路徑

vs2013編譯zlib1 2 8庫解決方案

一 zlib庫的編譯 1.首先開啟vs2013的command prompt 32bit 也就是命令提示視窗。2.進入到zlib 1.2.5 contrib masmx86目錄,執行bld ml32.bat。同理,64位的電腦進入masmx64目錄,執行bld ml64.bat 這一步執行bld m...

VS2013崩潰,無法開啟專案的解決方案

最近遇到vs2013,在開啟解決方案時,報如下錯誤 未找到與約束 contractname microsoft.internal.visualstudio.platformui.isolutionattachedcollectionservice requiredtypeidentity micro...

「VS2013無法連線遠端資料庫」解決方案

vs2013無法連線遠端資料庫 解決方案 以管理員身份登入cmd,輸入netsh winsock reset並回車 注意,必須是已管理員身份執行,這個重置lsp連線 或 netsh winsock reset catalog 異常原因 由於一些非 ifs winsock 基礎服務提供商 bsp 或分...