kgober / FSX

File System Exchange, a utility to access data stored in disk images
MIT License
8 stars 1 forks source link

Can't build, dotnet can't load project file: Root element is missing #2

Open bastetfurry opened 1 month ago

bastetfurry commented 1 month ago

Tried to "dotnet build" your tool and got this little output:

(base) ➜  FSX git:(master) dotnet build

Willkommen bei .NET 8.0!
---------------------
SDK-Version: 8.0.107

----------------
Ein ASP.NET Core-HTTPS-Entwicklungszertifikat installiert.
Um dem Zertifikat zu vertrauen, sehen Sie sich die folgenden Anweisungen an: https://aka.ms/dotnet-https-linux

----------------
Schreiben Sie Ihre erste App: https://aka.ms/dotnet-hello-world
Neuigkeiten: https://aka.ms/dotnet-whats-new
Dokumentation: https://aka.ms/dotnet-docs
Probleme melden und Quelle in GitHub suchen: https://github.com/dotnet/core
verwenden Sie "dotnet --help", um verfügbare Befehle anzuzeigen, oder besuchen Sie https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
MSBuild-Version 17.8.5+b5265ef37 für .NET
MSBUILD : error MSB4025: Die Projektdatei konnte nicht geladen werden. Root element is missing.

Fehler beim Buildvorgang.

MSBUILD : error MSB4025: Die Projektdatei konnte nicht geladen werden. Root element is missing.
    0 Warnung(en)
    1 Fehler

Verstrichene Zeit 00:00:00.05

OS: Ubuntu 24.04 Dotnet: 8.0.107

Is there some special build instruction i need to follow as you wrote no build instructions?

kgober commented 1 month ago

The project files are set up for Visual Studio 2005 and Microsoft .NET Framework 2.0, for which the build instructions are obvious: choose Build from the Visual Studio menu. But as you've discovered, it is definitely not obvious what to do if you arent' using Visual Studio.

Here's a diff to get the project file into something dotnet will recognize:

--- FSX.csproj.orig     2020-10-12 12:10:16.895155361 +0000
+++ FSX.csproj  2020-10-12 12:12:15.887744835 +0000
@@ -1,4 +1,11 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+<!--xProject DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -60,7 +67,7 @@
   <ItemGroup>
     <None Include="App.config" />
   </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /-->
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
@@ -68,4 +75,5 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+<!--/xProject-->
+</Project>

I had to use "dotnet build FSX.csproj". I don't know enough about .NET core yet to get just "dotnet build" by itself to work. I don't know enough yet to be sure this is even right. But it did compile for me at least. It made a DLL.

Also I have these diffs I've been working on but haven't committed yet:

--- Program.cs.orig     2020-10-12 12:01:02.369741570 +0000
+++ Program.cs  2020-10-12 15:14:21.617914334 +0000
@@ -154,17 +154,10 @@

         static void MountHostVolumes()
         {
-            foreach (DriveInfo drive in DriveInfo.GetDrives())
-            {
-                if (!drive.IsReady) continue;
-                String id = drive.Name;
-                if (id.EndsWith(@"\")) id = id.Substring(0, id.Length - 1);
-                if (id.EndsWith(@":")) id = id.Substring(0, id.Length - 1);
-                VolInfo vol = new VolInfo(id, new HostFS(drive.Name, drive.DriveFormat));
-                VolMap.Add(vol.ID, vol);
-                if (CurVol.ID == null) CurVol = vol;
-                Console.Error.WriteLine("{0}: = {1} [{2}]", id, drive.Name, vol.FS.Type);
-            }
+            VolInfo vol = new VolInfo("Host", new HostFS("/", "Linux"));
+            VolMap.Add(vol.ID, vol);
+            if (CurVol.ID == null) CurVol = vol;
+            Console.Error.WriteLine("{0}: = {1} [{2}]", "Host", "/", vol.FS.Type);
         }

         static void CommandLoop(TextReader input)
--- HostFS.cs.orig      2020-10-12 12:01:02.365741415 +0000
+++ HostFS.cs   2020-10-12 15:11:09.806898908 +0000
@@ -46,12 +46,12 @@

         public HostFS(String source, String format)
         {
-            if (source.EndsWith(@"\")) source = source.Substring(0, source.Length - 1);
+            if (source.EndsWith("/")) source = source.Substring(0, source.Length - 1);
             mSource = source;
             mType = String.Concat("Host/", format);
             mCWD = new DirectoryInfo(String.Concat(source, "."));
-            String dir = mCWD.FullName.Substring(2);
-            if (!dir.EndsWith(@"\")) dir = String.Concat(dir, @"\");
+            String dir = mCWD.FullName;
+            if (!dir.EndsWith("/")) dir = String.Concat(dir, "/");
             mDir = dir;
         }

@@ -82,11 +82,11 @@

         public override void ChangeDir(String dirSpec)
         {
-            String dir = (dirSpec.StartsWith(@"\")) ? dirSpec : String.Concat(mDir, dirSpec);
+            String dir = (dirSpec.StartsWith("/")) ? dirSpec : String.Concat(mDir, dirSpec);
             if (!IsValidDir(dir)) return;
             mCWD = new DirectoryInfo(dir);
             dir = mCWD.FullName.Substring(2);
-            if (!dir.EndsWith(@"\")) dir = String.Concat(dir, @"\");
+            if (!dir.EndsWith("/")) dir = String.Concat(dir, "/");
             mDir = dir;
         }

I do not recall how much testing (if any) these diffs had.

I have been meaning to learn .NET core; it's on my to-do list. I will leave this issue open until I commit a proper fix, or at least better instructions, but the diffs above will hopefully get you going in the meantime.