oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.64k stars 236 forks source link

Some NuGet packages are not recognized and not referenced #396

Closed UweKeim closed 23 hours ago

UweKeim commented 2 days ago

Suddenly, out of nowhere, I get errors because it seems CS-Script does not recognize all referenced NuGet packages anymore.

My script worked well before.

I tried this directly on the command line:

C:\Users\ukeim>dotnet tool update --global cs-script.cli
Das Tool "cs-script.cli" ist bereits installiert.

C:\Users\ukeim>css -config:set:LegacyNugetSupport=false
set: LegacyNugetSupport: False

C:\Users\ukeim>css -verbose -nuget:restore "C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\\do-build-all.cs"

Then, the beginning output of the last command is:

Restoring packages...
Mapping packages to assemblies...
Restoring packages...
Mapping packages to assemblies...
> ----------------
  Provider:
  Script engine: C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
  Compiler engine: dotnet (C:\Program Files\dotnet\dotnet.exe)
  Console Encoding: Codepage - 850 (Codepage - 850) - system default
  CurrentDirectory: C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build
  CurrentProcess: 56700
  NuGet manager: dotnet
  NuGet cache: C:\Users\ukeim\.nuget\packages
  Script cache: C:\Users\ukeim\AppData\Local\Temp\csscript.core\cache
  Executing: C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\do-build-all.cs
  Hosting: InProcess
  Script arguments:
  SearchDirectories:
    ------- (local dirs) -------
    0 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build
    1 - C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any
    ------- (dirs from cmd args) -------
    ------- (dirs from code) -------
    2 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper
    3 - C:\Users\ukeim\.nuget\packages\sharpziplib\1.4.2\lib\net6.0
    4 - C:\Users\ukeim\.nuget\packages\jetbrains.annotations\2024.3.0\lib\netstandard2.0
    5 - C:\Users\ukeim\.nuget\packages\morelinq\4.3.0\lib\net8.0
    6 - C:\Users\ukeim\.nuget\packages\newtonsoft.json\13.0.3\lib\net6.0
    7 - C:\Users\ukeim\.nuget\packages\nuget.versioning\6.12.1\lib\netstandard2.0
    8 - C:\Users\ukeim\.nuget\packages\quickuploader.webapiaccessor\1.0.248\lib\net9.0
    9 - C:\Users\ukeim\.nuget\packages\restsharp\112.1.0\lib\net8.0
    10 - C:\Users\ukeim\.nuget\packages\zetadeployer.runtimeuploader\1.0.96\lib\net8.0
    11 - C:\Users\ukeim\.nuget\packages\zetashortpaths\2.0.41\lib\net8.0
    ------- (dirs from config) -------
    12 - C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\lib
    13 - C:\ProgramData\cs-script\commands
    14 - C:\ProgramData\cs-script\inc
    ------- (cs-script special dirs) -------
    15 - C:\Users\ukeim\AppData\Local\Temp\csscript.core\cache\475058790
> ----------------

It starts promising, as it correctly detects "sharpziplib".

The output continues:

Compiling script...

  Precompilers:
   0 - do-build-all.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   1 - Afx.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   2 - AppOfflineUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   3 - BuildUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   4 - CompilationUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   5 - FileSyncUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   6 - FileUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   7 - FolderUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   8 - FolderXCopy.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   9 - FolderXCopyUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   10 - FolderZip.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   11 - Logging.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   12 - ProcessUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   13 - QuickUploaderUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   14 - SpecialFolders.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   15 - StringUtilities.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   16 - ExcelImport.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   17 - FileHelper.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   18 - ModelHelper.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   19 - ProjektvorlageModel.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   20 - ProjektvorlageProcessor.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll
   21 - TagsController.cs -> csscript.DefaultPrecompiler
           from C:\Users\ukeim\.dotnet\tools\.store\cs-script.cli\4.8.22\cs-script.cli\4.8.22\tools\net9.0\any\cscs.dll

Restoring packages...
Mapping packages to assemblies...
  Output file:
       C:\Users\ukeim\AppData\Local\Temp\csscript.core\56700.d5dd3e64-7928-490f-a05a-96a7cd6a7ec7.dll

  Files to compile:
   0 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\\do-build-all.cs
   1 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\Afx.cs
   2 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\AppOfflineUtilities.cs
   3 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\BuildUtilities.cs
   4 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\CompilationUtilities.cs
   5 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs
   6 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileUtilities.cs
   7 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderUtilities.cs
   8 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderXCopy.cs
   9 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderXCopyUtilities.cs
   10 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs
   11 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\Logging.cs
   12 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\ProcessUtilities.cs
   13 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\QuickUploaderUtilities.cs
   14 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\SpecialFolders.cs
   15 - C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\StringUtilities.cs
   16 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ExcelImport.cs
   17 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\FileHelper.cs
   18 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ModelHelper.cs
   19 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageModel.cs
   20 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs
   21 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\TagsController.cs
   22 - C:\Users\ukeim\AppData\Local\Temp\csscript.core\cache\475058790\do-build-all.attr.g.cs

  References:
   0 - C:\Users\ukeim\.nuget\packages\zetashortpaths\2.0.41\lib\net8.0\ZetaShortPaths.dll
   1 - C:\Users\ukeim\.nuget\packages\morelinq\4.3.0\lib\net8.0\MoreLinq.dll
   2 - C:\Users\ukeim\.nuget\packages\quickuploader.webapiaccessor\1.0.248\lib\net9.0\QuickUploader.WebApiAccessor.dll
   3 - C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\Aspose.Cells.dll
   4 - C:\Users\ukeim\.nuget\packages\newtonsoft.json\13.0.3\lib\net6.0\Newtonsoft.Json.dll
   5 - System.Core
   6 - System.Data.DataSetExtensions
   7 - System
   8 - C:\Users\ukeim\.nuget\packages\nuget.versioning\6.12.1\lib\netstandard2.0\NuGet.Versioning.dll
   9 - System.Data
   10 - System.Drawing
> ----------------

As you can see, the detected references do not include "sharpziplib" despite having //css_nuget SharpZipLib in my "do-build-all.cs" script.

The output then continues:

Compile: 22 error(s)
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(5,7): error CS0246:  Der Typ- oder Namespacename "ICSharpCode" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(6,7): error CS0246:  Der Typ- oder Namespacename "ICSharpCode" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(23,7): error CS0246:  Der Typ- oder Namespacename "Svg" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(27,19): error CS0234:  Der Typ- oder Namespacename "SqlServerCe" ist im Namespace "System.Data" nicht vorhanden. (M├Âglicherweise fehlt ein Assemblyverweis.)
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(603,12): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(651,12): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(605,43): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(275,3): error CS0246:  Der Typ- oder Namespacename "ZipOutputStream" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(367,3): error CS0246:  Der Typ- oder Namespacename "ZipOutputStream" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(1375,27): error CS1069:  Der Typname "Image" konnte nicht im Namespace "System.Drawing" gefunden werden. Dieser Typ wurde an Assembly "System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzuf├╝gen.
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(1383,27): error CS1069:  Der Typname "Image" konnte nicht im Namespace "System.Drawing" gefunden werden. Dieser Typ wurde an Assembly "System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzuf├╝gen.
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(5,7): error CS0246:  Der Typ- oder Namespacename "ICSharpCode" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(6,7): error CS0246:  Der Typ- oder Namespacename "ICSharpCode" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(23,7): error CS0246:  Der Typ- oder Namespacename "Svg" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(27,19): error CS0234:  Der Typ- oder Namespacename "SqlServerCe" ist im Namespace "System.Data" nicht vorhanden. (M├Âglicherweise fehlt ein Assemblyverweis.)
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(603,12): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(651,12): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs(605,43): error CS0246:  Der Typ- oder Namespacename "ZetaDeployer" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(275,3): error CS0246:  Der Typ- oder Namespacename "ZipOutputStream" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs(367,3): error CS0246:  Der Typ- oder Namespacename "ZipOutputStream" wurde nicht gefunden (m├Âglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(1375,27): error CS1069:  Der Typname "Image" konnte nicht im Namespace "System.Drawing" gefunden werden. Dieser Typ wurde an Assembly "System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzuf├╝gen.
C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs(1383,27): error CS1069:  Der Typname "Image" konnte nicht im Namespace "System.Drawing" gefunden werden. Dieser Typ wurde an Assembly "System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzuf├╝gen.
> ----------------
Building with dotnet engine...
Initialization time: 14379,8383 msec
Compilation time:    1790,8216 msec
Total load time:     5246,0129 msec
> ----------------

This did work before and now suddenly does not work.

I'm rather clueless and I thought this happened before but found no issue here so far to see what helped back then.

To add more information, my "C:\Users\ukeim.nuget\packages\sharpziplib" folder contains this structure:

C:\USERS\UKEIM\.NUGET\PACKAGES\SHARPZIPLIB
└───1.4.2
    │   .nupkg.metadata
    │   .signature.p7s
    │   sharpziplib.1.4.2.nupkg
    │   sharpziplib.1.4.2.nupkg.sha512
    │   sharpziplib.nuspec
    │
    ├───images
    │       sharpziplib-nuget-256x256.png
    │
    └───lib
        ├───net6.0
        │       ICSharpCode.SharpZipLib.dll
        │       ICSharpCode.SharpZipLib.pdb
        │       ICSharpCode.SharpZipLib.xml
        │
        ├───netstandard2.0
        │       ICSharpCode.SharpZipLib.dll
        │       ICSharpCode.SharpZipLib.pdb
        │       ICSharpCode.SharpZipLib.xml
        │
        └───netstandard2.1
                ICSharpCode.SharpZipLib.dll
                ICSharpCode.SharpZipLib.pdb
                ICSharpCode.SharpZipLib.xml

My question:

Do you have any idea what might go on or what might have happened?

oleg-shilo commented 1 day ago

Hey Uwe, I am not sure what is happening, but I can definitely look at it. I assume this script will trigger the problem:

//css_include global-usings
//css_nuget SharpZipLib

typeof(ICSharpCode.SharpZipLib.Zip.FastZip).print();

Can you also give me the context - the .NET SDK version

UweKeim commented 1 day ago

I've downloaded the latest source code of CS-Script and tried to debug it.

Here are some random thoughts.

When debugging through this section, the generated CSPROJ file, passed to dotnet restore and dotnet publish looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <RootNamespace>_59ffa5d1_390c_4d8c_9aa1_4b9064de83c7</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Svg" Version="3.2.3" />
    <PackageReference Include="morelinq" Version="*" />
    <PackageReference Include="Newtonsoft.Json" Version="*" />
    <PackageReference Include="NuGet.Versioning" Version="*" />
    <PackageReference Include="QuickUploader.WebApiAccessor" Version="*" />
    <PackageReference Include="RestSharp" Version="*" />
    <PackageReference Include="SharpZipLib" Version="*" />
    <PackageReference Include="ZetaDeployer.RuntimeUploader" Version="*" />
    <PackageReference Include="ZetaShortPaths" Version="*" />
    <PackageReference Include="Microsoft.SqlServer.Compact" Version="*" />

  </ItemGroup>
</Project>

The CSPROJ looks correct to me (the file references to my script files are still missing, but I do think this is OK).

After running the dotnet publish command, the output folder is nearly empty:

C:\USERS\UKEIM\APPDATA\LOCAL\TEMP\CSSCRIPT.CORE\NUGET\59FFA5D1-390C-4D8C-9AA1-4B9064DE83C7
│   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj
│   Class1.cs
│
├───bin
│   └───Release
│       └───net9.0
│               59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.deps.json
│               59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.dll
│               59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.pdb
│
├───obj
│   │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj.nuget.dgspec.json
│   │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj.nuget.g.props
│   │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj.nuget.g.targets
│   │   project.assets.json
│   │   project.nuget.cache
│   │
│   └───Release
│       └───net9.0
│           │   .NETCoreApp,Version=v9.0.AssemblyAttributes.cs
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.AssemblyInfo.cs
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.AssemblyInfoInputs.cache
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.assets.cache
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj.CoreCompileInputs.cache
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.csproj.FileListAbsolute.txt
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.dll
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.GeneratedMSBuildEditorConfig.editorconfig
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.GlobalUsings.g.cs
│           │   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.pdb
│           │   PublishOutputs.7074de2593.txt
│           │
│           ├───ref
│           │       59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.dll
│           │
│           └───refint
│                   59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.dll
│
└───publish
        59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.deps.json
        59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.dll
        59ffa5d1-390c-4d8c-9aa1-4b9064de83c7.pdb

Therefore, this call (which contains a bug, IMO) returns an empty allRefAssemblies array.

Later on, it generates the final CSPROJ file to send to the compiler:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <AssemblyName>do-build-all</AssemblyName>
  </PropertyGroup>
  <PropertyGroup>
    <DefineConstants>TRACE;NETCORE;CS_SCRIPT</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.Threading.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\System.Threading\4.0.11\lib\netcore50\System.Threading.dll</HintPath>
    </Reference>
    <Reference Include="Aspose.Cells.dll">
      <HintPath>C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\Aspose.Cells.dll</HintPath>
    </Reference>
    <Reference Include="System.Linq.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\System.Linq\4.1.0\lib\netcore50\System.Linq.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\newtonsoft.json\9.0.1\lib\netstandard1.0\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="MoreLinq.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\morelinq\4.3.0\lib\netstandard2.1\MoreLinq.dll</HintPath>
    </Reference>
    <Reference Include="Svg.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\svg\3.2.3\lib\netcoreapp3.0\Svg.dll</HintPath>
    </Reference>
    <Reference Include="NuGet.Versioning.dll">
      <HintPath>C:\Users\ukeim\.nuget\packages\nuget.versioning\6.9.1\lib\netstandard2.0\NuGet.Versioning.dll</HintPath>
    </Reference>
    <Reference Include="cscs.dll">
      <HintPath>C:\Ablage\cs-script-master\src\cscs\bin\Debug\net8.0\cscs.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\do-build-all.cs" Link="do-build-all.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\Afx.cs" Link="Afx.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\AppOfflineUtilities.cs" Link="AppOfflineUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\BuildUtilities.cs" Link="BuildUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\CompilationUtilities.cs" Link="CompilationUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileSyncUtilities.cs" Link="FileSyncUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FileUtilities.cs" Link="FileUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderUtilities.cs" Link="FolderUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderXCopy.cs" Link="FolderXCopy.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderXCopyUtilities.cs" Link="FolderXCopyUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\FolderZip.cs" Link="FolderZip.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\Logging.cs" Link="Logging.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\ProcessUtilities.cs" Link="ProcessUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\QuickUploaderUtilities.cs" Link="QuickUploaderUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\SpecialFolders.cs" Link="SpecialFolders.cs" />
    <Compile Include="C:\P\zp-17.0\_References\Submodules\zeta-shared-ci-assets\DevelopmentTools\CentralScripts\StringUtilities.cs" Link="StringUtilities.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ExcelImport.cs" Link="ExcelImport.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\FileHelper.cs" Link="FileHelper.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ModelHelper.cs" Link="ModelHelper.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageModel.cs" Link="ProjektvorlageModel.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\ProjektvorlageProcessor.cs" Link="ProjektvorlageProcessor.cs" />
    <Compile Include="C:\P\zp-17.0\ZetaProducerContent\Development\Projects\Build\Helper\TagsController.cs" Link="TagsController.cs" />
    <Compile Include="C:\Users\ukeim\AppData\Local\Temp\csscript.core\cache\475058790\do-build-all.attr.g.cs" Link="do-build-all.attr.g.cs" />
  </ItemGroup>
</Project>

Here, to my surprise, the initial (correct) <PackageReference..>-Entries are not present anymore.

oleg-shilo commented 1 day ago

I will have a look and compare the packages folder structure. A few points:

D:\dev\support>css test Restoring packages... Mapping packages to assemblies... {ICSharpCode.SharpZipLib.Zip.FastZip} .Assembly = {ICSharpCode.SharpZipLib, Version=1.4.2.13, Culture=neutral, PublicKeyToken=1b03e6acf1164f73} .AssemblyQualifiedName = "ICSharpCode.SharpZipLib.Zip.FastZip, ICSharpCode.SharpZipLib, Version=1.4.2.13, Culture=neutral, PublicKeyToken=1b03e6acf1164f73" .Attributes = Public, BeforeFieldInit .BaseType = {object} .ContainsGenericParameters = False . . .



Will let you know the folder structure comparison outcome.
UweKeim commented 1 day ago

Thanks, @oleg-shilo.

In the final CSPROJ that gets sent to the dotnet build, the <PackageReference ...> entries are not present anymore and replaced by the assemblies that you looked up.

Do I have an option to skip the whole "self-made" lookup mechanism and simply have all (correctly!) detected <PackageReference ...> entires be present in the final CSPROJ file?

UweKeim commented 1 day ago

Can you also give me the context - the .NET SDK version

I'm having the following .NET SDKs on my machine:

C:\Users\ukeim>dotnet --list-sdks
6.0.428 [C:\Program Files\dotnet\sdk]
7.0.120 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
9.0.100 [C:\Program Files\dotnet\sdk]

I could also assemble a test script if it would help you.

Personally, I do think that is something that happend on my machine that suddenly breaks the scripts; I just don't know what.

UweKeim commented 1 day ago

I assume this script will trigger the problem:

//css_include global-usings
//css_nuget SharpZipLib

typeof(ICSharpCode.SharpZipLib.Zip.FastZip).print();

To my surprise, this compiles successfully on my machine 😢.

UweKeim commented 23 hours ago

OK, I do think I figured it out:

My script also included another file //css_import Helper\ProjektvorlageProcessor that contains this code:

//css_nuget -force:3600 -ver:3.2.3 -ng:"-Source https://nuget.org/api/v2/" Svg
//css_nuget -force:3600 -ng:"-Source https://nuget.org/api/v2/" Microsoft.SqlServer.Compact

This was a fragment from when I used the old CS-Script that runs with .NET Framework.

After changing it to this:

//css_nuget Svg
//css_nuget Microsoft.SqlServer.Compact

My script compiles successfully.

I still don't know why the "old" NuGet reference syntax causes this behavior, but at least I do have an explanation and a fix now.

Sorry for bothering you with my problems that I caused by myself.

I leave this here to publicly shame myself and to maybe help someone in the future (possibly including myself).

oleg-shilo commented 22 hours ago

...I leave this here to publicly shame myself ...

Not at all. This is a struggle that everyone would have to go through given the circumstances. I know I have been there once or twice. Likely your old //css_nuget is causing the version clash. But most likely it sets the local source and then it leads to dependency confusion of a sort.

I think it makes sense to update the project generation output to help with the troubleshooting. Currently, this is what it does:

image

But it should include the nuget packages requested.

Also something similar might be printed in the output when the packages are being resolved. Currently it simply says "Resolving packages..."

I am changing this issue to the "Enhancement".

oleg-shilo commented 21 hours ago

This is how it is going to be in the next release:

image

UweKeim commented 21 hours ago

This is a great enhancement, Oleg. Thank you very much 😊

oleg-shilo commented 20 hours ago

I also updated the new restore algorithm which is to print the packages so it can help with the CI logs.

image

Note, the legacy algorithm already prints the output on nuget.exe. So there is no need to print the package names from the cs-script since nuget.exe does it anyway.