SLN文件中的GUID
时间:2020-03-05 18:50:24 来源:igfitidea点击:
Visual Studio解决方案文件每个项目条目包含两个GUID。我认为其中之一是来自AssemblyInfo.cs
谁能确定这些来源和用途?
解决方案
回答
根据MSDN:
[The Project] statement contains the unique project GUID and the project type GUID. This information is used by the environment to find the project file or files belonging to the solution, and the VSPackage required for each project. The project GUID is passed to IVsProjectFactory to load the specific VSPackage related to the project, then the project is loaded by the VSPackage.
回答
两个GUID都不与AssemblyInfo.cs中的GUID相同(GUID是程序集本身的GUID,与Visual Studio无关,但与构建的最终产品无关)。
因此,对于sln文件中的典型行(如果要查看此内容,请在记事本或者选择项编辑器中打开.sln):
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}"
第二个GUID是项目本身的唯一GUID。解决方案文件使用此文件将其他设置映射到该项目:
GlobalSection(ProjectConfigurationPlatforms) = postSolution {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
第一个GUID实际上是一个GUID,它是解决方案本身的唯一GUID(我相信)。如果解决方案包含多个项目,则实际上会看到类似以下内容的内容:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "..\CompositeWPF\Source\CAL\Composite\Composite.csproj", "{77138947-1D13-4E22-AEE0-5D0DD046CA34}" EndProject