Skip to content

dotnet pack: glob with forward slashes doesn't work on windows in nuspec file #49950

@Yury-Fridlyand

Description

@Yury-Fridlyand

Describe the bug

I use a windows PC for development, but I test all CI commands on WSL too.
A glob expression in a nuspec file like

<file src="/api/flow.js?q=https%3A%2F%2Fgithub.com%2Fdotnet%2Fsdk%2Fissues%2Fbin%2FRelease%2F**%2F*" ...

works fine on linux and windows both, but if I use forward slashes

<file src="/api/flow.js?q=https%3A%2F%2Fgithub.com%2Fdotnet%2Fsdk%2Fissues%2Fbin%2FRelease%2F**%2F*" ...

It works on linux only.

To Reproduce

nuspec file with forward slashes: https://github.com/Yury-Fridlyand/valkey-glide/blob/037bb2fabfbb75045a4b22048707333661a1145c/csharp/sources/Valkey.Glide/Valkey.Glide.nuspec#L27-L31
Same with back slashes: https://github.com/Yury-Fridlyand/valkey-glide/blob/fa30122df1f7012c9211521a410ed60eccb6af69/csharp/sources/Valkey.Glide/Valkey.Glide.nuspec#L27-L31

To try the build, comment out lines 45-50, set env var SkipCargo=true and run

dotnet build Valkey.Glide.csproj --configuration Release
dotnet pack Valkey.Glide.csproj --configuration Release

(the full CD pipeline is here if you need it)

So on linux everything works fine, regardless of the path separator:

dotnet build Valkey.Glide.csproj --configuration Release
Restore complete (1.6s)
  Valkey.Glide net6.0 succeeded (5.1s) → bin/Release/net6.0/Valkey.Glide.dll
  Valkey.Glide net8.0 succeeded (5.8s) → bin/Release/net8.0/Valkey.Glide.dll

Build succeeded in 8.1s

$ dotnet pack Valkey.Glide.csproj --configuration Release
Restore complete (1.3s)
  Valkey.Glide net6.0 succeeded (4.0s) → bin/Release/net6.0/Valkey.Glide.dll
  Valkey.Glide net8.0 succeeded (4.1s) → bin/Release/net8.0/Valkey.Glide.dll

Build succeeded in 14.6s

The nukpg content:

├── Valkey.Glide.nuspec
├── [Content_Types].xml
├── _rels
├── docs
│   └── README.md
├── lib
│   ├── net6.0
│   │   ├── Valkey.Glide.dll
│   │   └── Valkey.Glide.xml
│   └── net8.0
│       ├── Valkey.Glide.dll
│       └── Valkey.Glide.xml
└── package
    └── services
        └── metadata
            └── core-properties
                └── 7ecbae24e48c4dd5b942edc07150c8bc.psmdcp

10 directories, 8 files

Dotnet on windows with backslashes works fine too, but with forward slashes:

> dotnet build Valkey.Glide.csproj --configuration Release /property:Version=1.2.6-rc4
Restore complete (0,7s)
  Valkey.Glide net6.0 succeeded (17,4s) → bin\Release\net6.0\Valkey.Glide.dll
  Valkey.Glide net8.0 succeeded (18,2s) → bin\Release\net8.0\Valkey.Glide.dll

Build succeeded in 19,4s

> dotnet pack Valkey.Glide.csproj --configuration Release "-p:NuspecProperties=Version=1.2.6-rc4"
Restore complete (0,6s)
  Valkey.Glide net6.0 succeeded (1,0s) → bin\Release\net6.0\Valkey.Glide.dll
  Valkey.Glide net8.0 succeeded (1,4s) → bin\Release\net8.0\Valkey.Glide.dll
  Valkey.Glide succeeded with 12 warning(s) (0,5s)
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net6.0\Valkey.Glide.dll' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net8.0\Valkey.Glide.dll' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net6.0\Valkey.Glide.xml' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net8.0\Valkey.Glide.xml' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128:
      Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the l
      ist of actions below:
      - Add a dependency group for bin0.0 to the nuspec
      - Add lib or ref assemblies for the net6.0 target framework
      - Add lib or ref assemblies for the net8.0 target framework
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net6.0\Valkey.Glide.dll' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net8.0\Valkey.Glide.dll' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net6.0\Valkey.Glide.xml' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net8.0\Valkey.Glide.xml' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net6.0\Valkey.Glide.pdb' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5103: The folder 'lib\bin\Release\net8.0\Valkey.Glide.pdb' under 'lib' is not recognized as a valid framework name or a supported culture identifier. Rename it to a valid framework name or culture identifier.
    C:\Program Files\dotnet\sdk\9.0.300\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5128:
      Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the l
      ist of actions below:
      - Add a dependency group for bin0.0 to the nuspec
      - Add lib or ref assemblies for the net6.0 target framework
      - Add lib or ref assemblies for the net8.0 target framework

Build succeeded with 12 warning(s) in 3,1s

And it did not place files in the right directory tree

├── Valkey.Glide.nuspec
├── [Content_Types].xml
├── _rels
├── docs
│   └── README.md
├── lib
│   └── bin
│       └── Release
│           ├── net6.0
│           │   ├── Valkey.Glide.dll
│           │   └── Valkey.Glide.xml
│           └── net8.0
│               ├── Valkey.Glide.dll
│               └── Valkey.Glide.xml
└── package
    └── services
        └── metadata
            └── core-properties
                └── 1da8a41205bc43cab23ce69bf0c7b28b.psmdcp

12 directories, 8 files

Further technical details

details of dotnet --info on windows

.NET SDK:
 Version:           9.0.300
 Commit:            15606fe0a8
 Workload version:  9.0.300-manifests.af4147de
 MSBuild version:   17.14.5+edd3bbf37

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.300\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.5
  Architecture: x64
  Commit:       e36e4d1a8f

.NET SDKs installed:
  8.0.118 [C:\Program Files\dotnet\sdk]
  8.0.315 [C:\Program Files\dotnet\sdk]
  8.0.412 [C:\Program Files\dotnet\sdk]
  9.0.300 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

details of dotnet --info on WSL

.NET SDK:
 Version:           9.0.203
 Commit:            dc7acfa194
 Workload version:  9.0.200-manifests.9df47798
 MSBuild version:   17.13.20+a4ef1e90f

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  24.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /home/yuryf/.dotnet/sdk/9.0.203/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.4
  Architecture: x64
  Commit:       f57e6dc747

.NET SDKs installed:
  8.0.406 [/home/yuryf/.dotnet/sdk]
  9.0.203 [/home/yuryf/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.13 [/home/yuryf/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.4 [/home/yuryf/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.13 [/home/yuryf/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.4 [/home/yuryf/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/yuryf/.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Workaround and thoughts

Use backslashes in glob and wildcard expressions. But it is unclear how symbol escaping rules work.
I'd like to have dotnet fully agnostic to path separator on any platform.
If it is impossible to fix (no way), please update the docs.

Similar issue: #39569

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions