如何解决通过较新的 Visual Studio 非 GUI(即 MSVC 构建)构建旧项目的问题;
C:\ext2fsd-code> msbuild Ext3Fsd.sln /p:Configuration=Release
MSBuild version 17.12.12+1cce77968 for .NET Framework
Build started 29-Dec-24 7:28:21 AM.
MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.
Build FAILED.
MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing
在.sln
文件中,
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext3Fsd", "Ext3Fsd\ext3fsd.vcproj", "{2328F787-71B4-408B-8E10-B7A95BF9A110}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Mgr", "Ext2Mgr\Ext2Mgr.vcproj", "{F0E304B5-AF20-49F7-8183-5994C6EA889D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ext2Srv", "Ext2Srv\Ext2Srv.vcproj", "{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}"
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 2
SccProjectUniqueName0 = Ext3Fsd\\ext3fsd.vcproj
SccProjectName0 = Ext3Fsd
SccLocalPath0 = Ext3Fsd
SccProvider0 = MSSCCI:Perforce\u0020P4\u0020SCM
CanCheckoutShared = true
SccProjectUniqueName1 = Ext2Srv\\Ext2Srv.vcproj
SccProjectName1 = Ext2Srv
SccLocalPath1 = Ext2Srv
SccProvider1 = MSSCCI:Perforce\u0020P4\u0020SCM
CanCheckoutShared = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2328F787-71B4-408B-8E10-B7A95BF9A110}.Debug|Win32.ActiveCfg =
Debug|Win32
{2328F787-71B4-408B-8E10-B7A95BF9A110}.Debug|Win32.Build.0 = Debug|Win32
{2328F787-71B4-408B-8E10-B7A95BF9A110}.Release|Win32.ActiveCfg = Release|Win32
{2328F787-71B4-408B-8E10-B7A95BF9A110}.Release|Win32.Build.0 = Release|Win32
{F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.ActiveCfg = Debug|Win32
{F0E304B5-AF20-49F7-8183-5994C6EA889D}.Debug|Win32.Build.0 = Debug|Win32
{F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.ActiveCfg = Release|Win32
{F0E304B5-AF20-49F7-8183-5994C6EA889D}.Release|Win32.Build.0 = Release|Win32
{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.ActiveCfg = Debug|Win32
{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Debug|Win32.Build.0 = Debug|Win32
{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.ActiveCfg = Release|Win32
{A18F670C-DA85-43F6-8620-99A2DD8CEF1A}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
为了理解,让我们看一下它的第一个 vcproject 文件,该文件已从 更改为UTF-8
,gb2312
并将一些行推迟到简洁:
C:\ext2fsd-code>type Ext3Fsd/ext3fsd.vcproj
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Ext3Fsd"
ProjectGUID="{2328F787-71B4-408B-8E10-B7A95BF9A110}"
SccProjectName="Ext3Fsd"
SccLocalPath="."
SccProvider="MSSCCI:Perforce P4 SCM"
Keyword="MakeFileProj"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\chk"
IntermediateDirectory=".\chk"
ConfigurationType="0"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine=".\DDKBuild.bat -W7XP chk ."
ReBuildCommandLine=".\DDKBuild.bat -W7XP chk . -ceZ"
CleanCommandLine=""
Output="Ext2Fsd.sys"
PreprocessorDefinitions=""
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\fre"
IntermediateDirectory=".\fre"
ConfigurationType="0"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine=".\DDKBuild.bat -W7XP fre ."
ReBuildCommandLine=".\DDKBuild.bat -W7XP fre . -cZ"
CleanCommandLine=""
Output="Ext3Fsd.sys"
PreprocessorDefinitions=""
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="access.c"
>
<Filter
Name="nls"
>
</Filter>
<Filter
Name="ext4" >
</Filter>
<Filter
Name="jbd"
>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<Filter
Name="Linux"
>
<File
RelativePath="include\linux\atomic.h">
<File
RelativePath="include\linux\bitops.h"
</File>
</Filter>
<Filter
Name="asm"
>
</Filter>
</Filter>
<Filter
Name="Resource Files"
</Filter>
<Filter
Name="Douments"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
请帮助指导/指出为什么会出现这样的错误,非常感激
从查看此文档MSB4025来看,当 MSBuild 尝试加载和解析项目但无法加载项目文件或 MSBuild 导入文件时会发生错误。
针对该问题,请尝试以下操作:
1.从命令来看
msbuild Ext3Fsd.sln
,您实际上是在解决方案中构建项目。请打开您的项目文件 (.vcproj) 并检查它是否是有效的 XML MSBuild 文件。(例如)2.很难确定哪些文件导致了此问题,您可以运行以下命令以使用完整的诊断日志重新运行构建。
3.备份然后删除
vcproj.user
文件,然后重建您的项目。4.备份并在最新版本的 Visual Studio(例如:VS2022)中打开项目。Visual Studio 建议将项目升级到当前架构。然后运行命令再次构建解决方案。有关更多信息,请参阅从早期版本的 Visual Studio 升级 C++ 项目
这种 CLI 方式无法做到这一点(至少目前,据我所知)。
因此,要获得“真正的”Microsoft Visual Studio IDE 版本 Community 2022,其可执行二进制文件名
devenv
启动后,其向导就会像魔法一样运行。它会立即升级/更新,将旧的 Visual Studio 版本项目迁移到最新版本。
可以比较文件
.vcxproj
和.vcproj
剩余文件。