diff --git a/src/Runtime/Nuget/XSPackNuget.prgx b/src/Runtime/Nuget/XSPackNuget.prgx index b00ed3a719..6b801eaff8 100644 --- a/src/Runtime/Nuget/XSPackNuget.prgx +++ b/src/Runtime/Nuget/XSPackNuget.prgx @@ -4,64 +4,98 @@ USING System.Linq USING System.Text USING System.Diagnostics +// What XSharp package are we building ? VAR Tool := "" IF Args:Count >= 1 Tool := Args[0] ENDIF +// Per default, XSharp root is three levels up ( we are in src/runtime/Nuget) VAR Root := "..\..\.." +// Create the packages with the Release VAR Build := "Release" +VAR TFM = "Net46+Net8.0" +// The version file is in src\Common VAR VersionFile := Root + "\src\Common\BuildNumber.h" - +// Per default, Retrieve the version number VAR Version := GetBuildNumber( VersionFile ) +// Parameter for Build ? IF Args:Count >= 2 Build := Args[1] ENDIF -VAR SourceFolder := Root + "\Artifacts\" + Build +// For a Single TFM, this could work +VAR SourceFolders := Root + "\Artifacts\" + Build VAR OutputFolder := Root + "\Artifacts\Packages\" + Build +// Parameter for TFM ? IF Args:Count >= 3 - SourceFolder := Args[2] + TFM := Args[2] ENDIF +VAR TfmCount := TFM:Count( { c => c == '+' } ) +// Parameter for SourceFolder, OutputFolder, Version ? IF Args:Count >= 4 - OutputFolder := Args[3] + SourceFolders := Args[3] +ENDIF +// If you pass some SourceFolders, check if the count match the TFM count +VAR srcCount := SourceFolders:Count( { c => c == '+' } ) +IF srcCount > 0 .AND. srcCount != TfmCount + ErrorMessage( "The number of SourceFolders must match the number of TFM specified." ) + Tool := "" +ELSE + // Adjust SourceFolders if multiple TFM + IF TfmCount >= 1 + SourceFolders := "" + VAR tfmList := TFM:Split( '+' ) + FOREACH VAR tfmItem IN tfmList + IF SourceFolders != "" + SourceFolders += "+" + ENDIF + SourceFolders += Root + "\Artifacts\" + Build + "\" + tfmItem + NEXT + ENDIF ENDIF IF Args:Count >= 5 - Version := Args[4] + OutputFolder := Args[4] +ENDIF +IF Args:Count >= 6 + Version := Args[5] ENDIF IF String.IsNullOrEmpty( Tool ) - Console.WriteLine( "Usage : XSPackNuget [ [ [ [] ] ] ] " ) - Console.WriteLine( " should be Core, RT, VOSDK, VO, VFP, XPP") - Console.WriteLine( " indicate the Build version to use. Release per default.") - Console.WriteLine( " indicate the Path where files are stored. Artifacts\ per default") - Console.WriteLine( " indicate the Path where the packages are generated. Artifacts\Packages\ per default") - Console.WriteLine( " indicate the version of the package to generate. Using current version number per default.") + InfoMessage( "Usage : XSPackNuget [ [ [ [ [] ] ] ] ] " ) + InfoMessage( " should be Core, RT, VOSDK, VO, VFP, XPP") + InfoMessage( " indicate the Build version to use. Release per default.") + InfoMessage( " indicate the Target Framework. Net46, Net80 or Net46+Net80. Net46+Net80 per default.") + InfoMessage( " indicate the Path where files are stored. Artifacts\\ per default") + InfoMessage( " For a single Tfm, indicate one source. For 2 Tfm, indicate two folders separated with a '+' sign. Artifacts\\+Artifacts\\") + InfoMessage( " indicate the Path where the packages are generated. Artifacts\Packages\ per default") + InfoMessage( " indicate the version of the package to generate. Using current version number per default.") RETURN ENDIF -Console.WriteLine( "Running XSPackNuget ..." ) -Console.WriteLine( "Tool : " + Tool ) -Console.WriteLine( "Build : " + Build ) -Console.WriteLine( "Source Folder : " + SourceFolder ) -Console.WriteLine( "Output Folder : " + OutputFolder ) -Console.WriteLine( "Version : " + Version ) -// +InfoMessage( "Running XSPackNuget ..." ) +InfoMessage( "Tool : " + Tool ) +InfoMessage( "Build : " + Build ) +InfoMessage( "Target Framework : " + TFM ) +InfoMessage( "Source Folder : " + SourceFolders ) +InfoMessage( "Output Folder : " + OutputFolder ) +InfoMessage( "Version : " + Version ) +// Check if Nuget is installed var result := CheckNuGet() IF ( ! result ) - Console.WriteLine( "The application 'Microsoft.NuGet' is NOT installed." ) - Console.WriteLine( "Please run : winget install Microsoft.NuGet" ) + ErrorMessage( "The application 'Microsoft.NuGet' is NOT installed." ) + InfoMessage( "Please run : winget install Microsoft.NuGet" ) RETURN ENDIF -CreateNuSpec( SourceFolder, Tool, Version ) +CreateNuSpec( TFM, SourceFolders, Tool, Version ) IF !RunNuget( Tool, Version, OutputFolder ) - Console.WriteLine( "Something went wrong...." ) + ErrorMessage( "Something went wrong...." ) ENDIF -Console.WriteLine( "Done." ) +InfoMessage( "Done." ) FUNCTION GetBuildNumber( versionFile AS STRING ) AS String VAR version := "3.0.0" @@ -102,15 +136,30 @@ FUNCTION CheckNuGet() AS LOGIC END USING RETURN result -PROCEDURE CreateNuSpec( sourceFolder AS STRING, tool AS String, version AS STRING ) +PROCEDURE CreateNuSpec( tfm AS STRING, sourceFolders AS STRING, tool AS String, version AS STRING ) VAR source := "XSharp." + tool + ".nuspec.txt" VAR destination := "XSharp." + tool + "." + version +".nuspec" VAR content := "" + VAR tfmList := tfm:Split('+') + VAR sourceFolder := sourceFolders:Split('+') // - content := File.ReadAllText( source ) - content := content:Replace( "$SourceFolder", sourceFolder ) - content := content:Replace( "$Version", version ) - File.WriteAllText( destination, content ) + IF File.Exists( source ) + VAR contentLines = File.ReadAllLines( source ) + FOREACH VAR line IN contentLines + IF line:Contains( "$SourceFolder" ) // We MUST also have a $TFM tag on the same line + FOR VAR i := 1 TO tfmList:Length + VAR tfmItem := tfmList[i] + VAR srcFolder := sourceFolder[i] + content += line:Replace( "$SourceFolder", srcFolder ):Replace( "$TFM", tfmItem ) + Environment.NewLine + NEXT + ELSE + content += line:Replace( "$Version", version ) + Environment.NewLine + ENDIF + NEXT + File.WriteAllText( destination, content ) + ELSE + ErrorMessage( "NuSpec template file not found : " + source ) + ENDIF // RETURN @@ -131,8 +180,23 @@ FUNCTION RunNuget( tool AS String, version AS STRING, outputDirectory AS STRING var execResult := reader:ReadToEnd() success := execResult:Contains( nupkg ) IF !success - Console.WriteLine( execResult ) + ErrorMessage( execResult ) ENDIF END USING END USING RETURN success + +FUNCTION ErrorMessage( msg AS STRING ) AS VOID + VAR clr = Console.ForegroundColor + Console.ForegroundColor = ConsoleColor.Red + Console.WriteLine( msg ) + Console.ForegroundColor = clr + RETURN + +FUNCTION InfoMessage( msg AS STRING ) AS VOID + VAR clr = Console.ForegroundColor + Console.ForegroundColor = ConsoleColor.White + Console.WriteLine( msg ) + Console.ForegroundColor = clr + RETURN + diff --git a/src/Runtime/Nuget/XSharp.Core.nuspec.txt b/src/Runtime/Nuget/XSharp.Core.nuspec.txt index 8ebdee3768..0b7ca747b8 100644 --- a/src/Runtime/Nuget/XSharp.Core.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.Core.nuspec.txt @@ -7,21 +7,17 @@ XSharp B.V. XSharp B.V. false - https://github.com/X-Sharp/XSharpPublic/src/License.txt + Apache-2.0 icon\Xsharp.png - Readme.md + Readme.md XSharp Core Copyright (C) 2015 and beyond by XSharp B.V. - XSharp, Core + XSharp, Core - - - - - + \ No newline at end of file diff --git a/src/Runtime/Nuget/XSharp.RT.nuspec.txt b/src/Runtime/Nuget/XSharp.RT.nuspec.txt index 5f018c31de..ccb260797e 100644 --- a/src/Runtime/Nuget/XSharp.RT.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.RT.nuspec.txt @@ -7,26 +7,21 @@ XSharp B.V. XSharp B.V. false - https://github.com/X-Sharp/XSharpPublic/src/License.txt + Apache-2.0 icon\Xsharp.png - Readme.md + Readme.md XSharp Runtime Copyright (C) 2015 and beyond by XSharp B.V. XSharp, Runtime - - - - - - - - - - + + + + + \ No newline at end of file diff --git a/src/Runtime/Nuget/XSharp.VFP.nuspec.txt b/src/Runtime/Nuget/XSharp.VFP.nuspec.txt index c931e78f49..95906e20f3 100644 --- a/src/Runtime/Nuget/XSharp.VFP.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.VFP.nuspec.txt @@ -7,23 +7,18 @@ XSharp B.V. XSharp B.V. false - https://github.com/X-Sharp/XSharpPublic/src/License.txt + Apache-2.0 icon\Xsharp.png - Readme.md + Readme.md XSharp Visual FoxPro Runtime Copyright (C) 2015 and beyond by XSharp B.V. XSharp, VFP, Runtime - - - - - - - + + \ No newline at end of file diff --git a/src/Runtime/Nuget/XSharp.VO.nuspec.txt b/src/Runtime/Nuget/XSharp.VO.nuspec.txt index 4e6e064c43..69b1e30920 100644 --- a/src/Runtime/Nuget/XSharp.VO.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.VO.nuspec.txt @@ -7,22 +7,17 @@ XSharp B.V. XSharp B.V. false - https://github.com/X-Sharp/XSharpPublic/src/License.txt + Apache-2.0 icon\Xsharp.png - Readme.md + Readme.md XSharp Visual Objects Runtime Copyright (C) 2015 and beyond by XSharp B.V. XSharp, VO, Runtime - - - - - - + \ No newline at end of file diff --git a/src/Runtime/Nuget/XSharp.VOSDK.nuspec.txt b/src/Runtime/Nuget/XSharp.VOSDK.nuspec.txt index 724c649a79..5ac6b145ef 100644 --- a/src/Runtime/Nuget/XSharp.VOSDK.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.VOSDK.nuspec.txt @@ -5,8 +5,8 @@ $Version XSharp Visual Objects SDK Classes XSharp B.V. - XSharp B.V. - https://github.com/X-Sharp/XSharpPublic/src/License.txt + XSharp B.V. + Apache-2.0 icon\Xsharp.png Readme.md false @@ -14,23 +14,17 @@ Copyright (C) 2015 and beyond by XSharp B.V. XSharp, VOSDK - - - - - - - - - - - - - + + + + + + + diff --git a/src/Runtime/Nuget/XSharp.XPP.nuspec.txt b/src/Runtime/Nuget/XSharp.XPP.nuspec.txt index 672fb602bb..d57767976a 100644 --- a/src/Runtime/Nuget/XSharp.XPP.nuspec.txt +++ b/src/Runtime/Nuget/XSharp.XPP.nuspec.txt @@ -7,22 +7,17 @@ XSharp B.V. XSharp B.V. false - https://github.com/X-Sharp/XSharpPublic/src/License.txt + Apache-2.0 icon\Xsharp.png - Readme.md + Readme.md XSharp XBase++ Runtime Copyright (C) 2015 and beyond by XSharp B.V. XSharp, XPP, Runtime - - - - - - + \ No newline at end of file