Browse Source

Fixes #3790. Can't build v2_develop RELEASE - "The local source 'C:\Users\Tig\s\gui-cs\Terminal.Gui\local_packages' doesn't exist." (#3794)

BDisp 9 months ago
parent
commit
8f1954f16c

+ 0 - 4
.gitignore

@@ -34,9 +34,6 @@ _ReSharper.**
 ~$*
 *~
 
-# NuGet Stuff
-*.nupkg
-*.snupkg
 # Exclude everything in packages directory except the packages/build directory
 **/[Pp]ackages/*
 !**/[Pp]ackages/build/
@@ -61,4 +58,3 @@ demo.*
 *.tui/
 
 *.dotCover
-/local_packages/

+ 0 - 9
NativeAot/PackTerminalGui.ps1

@@ -1,9 +0,0 @@
-# Step 1: Build and pack Terminal.Gui
-dotnet build ../Terminal.Gui/Terminal.Gui.csproj --configuration Release
-dotnet pack ../Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ../local_packages
-
-# Step 2: Restore NativeAot with the new package
-dotnet restore ./NativeAot.csproj --source ./local_packages
-
-# Step 3: Build NativeAot
-dotnet build ./NativeAot.csproj --configuration Release

+ 0 - 11
NativeAot/PackTerminalGui.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-# Step 1: Build and pack Terminal.Gui
-dotnet build ../Terminal.Gui/Terminal.Gui.csproj --configuration Release
-dotnet pack ../Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ../local_packages
-
-# Step 2: Restore NativeAot with the new package
-dotnet restore ./NativeAot.csproj --source ./local_packages
-
-# Step 3: Build NativeAot
-dotnet build ./NativeAot.csproj --configuration Release

+ 0 - 9
SelfContained/PackTerminalGui.ps1

@@ -1,9 +0,0 @@
-# Step 1: Build and pack Terminal.Gui
-dotnet build ../Terminal.Gui/Terminal.Gui.csproj --configuration Release
-dotnet pack ../Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ../local_packages
-
-# Step 2: Restore SelfContained with the new package
-dotnet restore ./SelfContained.csproj --source ./local_packages
-
-# Step 3: Build SelfContained
-dotnet build ./SelfContained.csproj --configuration Release

+ 0 - 11
SelfContained/PackTerminalGui.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-# Step 1: Build and pack Terminal.Gui
-dotnet build ../Terminal.Gui/Terminal.Gui.csproj --configuration Release
-dotnet pack ../Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ../local_packages
-
-# Step 2: Restore SelfContained with the new package
-dotnet restore ./SelfContained.csproj --source ./local_packages
-
-# Step 3: Build SelfContained
-dotnet build ./SelfContained.csproj --configuration Release

+ 33 - 1
Terminal.Gui/Terminal.Gui.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <!-- =================================================================== -->
   <!-- Version numbers -->
   <!-- Automatically updated by gitversion (run `dotnet-gitversion /updateprojectfiles`)  -->
@@ -142,4 +142,36 @@
     <Authors>Miguel de Icaza, Tig Kindel (@tig), @BDisp</Authors>
   </PropertyGroup>
   <ProjectExtensions><VisualStudio><UserProperties resources_4config_1json__JsonSchema="../../docfx/schemas/tui-config-schema.json" /></VisualStudio></ProjectExtensions>
+
+  <Target Name="CopyNuGetPackagesToLocalPackagesFolder"
+          AfterTargets="Pack"
+          Condition="'$(Configuration)' == 'Release'">
+      <PropertyGroup>
+          <!-- Define the path for local_packages relative to the project directory -->
+          <LocalPackagesPath>$(MSBuildThisFileDirectory)..\local_packages\</LocalPackagesPath>
+          <!-- Output path without framework-specific folders -->
+          <PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</PackageOutputPath>
+      </PropertyGroup>
+
+      <!-- Ensure the local_packages folder exists -->
+      <Message Text="Checking if $(LocalPackagesPath) exists, creating if necessary." Importance="high" />
+      <MakeDir Directories="$(LocalPackagesPath)" />
+
+      <!-- Collect .nupkg and .snupkg files into an item group -->
+      <ItemGroup>
+          <NuGetPackages Include="$(PackageOutputPath)*.nupkg;$(PackageOutputPath)*.snupkg" />
+      </ItemGroup>
+
+      <!-- Check if any packages were found -->
+      <Message Text="Found packages: @(NuGetPackages)" Importance="high" />
+
+      <!-- Copy files only if found -->
+      <Copy SourceFiles="@(NuGetPackages)"
+            DestinationFolder="$(LocalPackagesPath)"
+            SkipUnchangedFiles="false"
+            Condition="@(NuGetPackages) != ''" />
+
+      <!-- Log success -->
+      <Message Text="Copy completed successfully." Importance="high" />
+  </Target>
 </Project>

+ 33 - 0
UnitTests/LocalPackagesTests.cs

@@ -0,0 +1,33 @@
+namespace Terminal.Gui;
+
+public class LocalPackagesTests
+{
+    private readonly string _localPackagesPath;
+
+    public LocalPackagesTests ()
+    {
+        // Define the local_packages path relative to the solution directory
+        _localPackagesPath = Path.Combine (Directory.GetCurrentDirectory (), "..", "..", "..", "..", "local_packages");
+    }
+
+    [Fact]
+    public void LocalPackagesFolderExists ()
+    {
+        Assert.True (Directory.Exists (_localPackagesPath),
+                     $"The local_packages folder does not exist: {_localPackagesPath}");
+    }
+
+    [Fact]
+    public void NupkgFilesExist ()
+    {
+        var nupkgFiles = Directory.GetFiles (_localPackagesPath, "*.nupkg");
+        Assert.NotEmpty (nupkgFiles);
+    }
+
+    [Fact]
+    public void SnupkgFilesExist ()
+    {
+        var snupkgFiles = Directory.GetFiles (_localPackagesPath, "*.snupkg");
+        Assert.NotEmpty (snupkgFiles);
+    }
+}

BIN
local_packages/Terminal.Gui.2.0.0.nupkg


BIN
local_packages/Terminal.Gui.2.0.0.snupkg