sdk: dotnet pack always failed on Ubuntu-18.04 with dotnet-sdk-3.0-preview3

Overview

dotnet pack command always failed in Ubuntu-18.04 in dotnet-sdk-3.0-preview3. if dotnet-sdk-2.2 was used, it successed.

Environment

platform is ubuntu-18.04-x64(created from azure virtual machine)

here is my dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview3-010431
 Commit:    d72abce213

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /home/itn/dotnet/sdk/3.0.100-preview3-010431/

Host (useful for support):
  Version: 3.0.0-preview3-27503-5
  Commit:  3844df9537

.NET Core SDKs installed:
  3.0.100-preview3-010431 [/home/itn/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [/home/itn/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [/home/itn/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Steps to reproduce

  1. download dotnet-sdk-3.0-preview3 for linux-x64 from SDK’s download page
  2. extract archive to directory($HOME/dotnet)
  3. add $HOME/dotnet to $PATH env
  4. run dotnet new classlib --name test1
  5. change directory to test1
  6. change TargetFramework to netstandard2.1
  7. run dotnet pack

Expected Behavior

test1.nupkg was created in bin directory.

Actual Behavior

failed to create nupkg with following error message.

/home/itn/dotnet/sdk/3.0.100-preview3-010431/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(199,5): error NU5019: File not found: '/home/itn/test1/bin/Debug/netstandard2.1/test1.dll'. [/home/itn/test1/test1.csproj]

/home/itn/test1/bin/Debug/netstandard2.1/test1.dll was created successfuly. I also tried to change TargetFramework to netstandard2.0, but did not success.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Is there a known workaround for this? I’m getting the same issue under WSL 2.

As pointed out by @stephentoub, the issue can be solved by manually setting the LANG environment variable.

export LANG=en-US.UTF-8

Okay, this is funny, but I have nailed down the issue. It’s a bug in System.Text.RegularExpressions on WSL.

The applicaiton

using System;
using System.Text.RegularExpressions;

namespace ConsoleDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            string test = @"Parent/Child.Grand.Child";
            Regex reg = new Regex('^' + Regex.Escape(test) + '$', RegexOptions.IgnoreCase);

            Console.WriteLine("Test string: {0}", test);
            Console.WriteLine("Regex: {0}", reg);
            Console.WriteLine("Regex.IsMatch: {0}", reg.IsMatch(test));
        }
    }
}

Output on vanilla Ubuntu 18.04

Test string: Parent/Child.Grand.Child
Regex: ^Parent/Child\.Grand\.Child$
Regex.IsMatch: True

Output on WSL Ubuntu 18.04

Test string: Parent/Child.Grand.Child
Regex: ^Parent/Child\.Grand\.Child$
Regex.IsMatch: False

Removing RegexOptions.IgnoreCase option fixes the output on WSL as well.

Why this affects dotnet pack

NuGet is filtering files by the exclude parameter using Regex here:

Which results into file not found exceptions, since no files pass the regex filter.

Apart of fixing the regex issue, NuGet shall not throw FileNotFound exception if the file exists, but filtered out by the exclusions.

Since this is blocking a beta-release of ours, I decided to strip as much as possible to see if I could find a way around this. I’ve found it’s reproducible every time even on a new, empty project.

mkdir app1
cd app1
dotnet new console
dotnet pack

Microsoft (R) Build Engine version 16.2.0-preview-19278-01+d635043bd for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 17.19 ms for /home/per/proj/app1/app1.csproj.
/home/per/dotnet/sdk/3.0.100-preview6-012264/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(158,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/home/per/proj/app1/app1.csproj]
  app1 -> /home/per/proj/app1/bin/Debug/netcoreapp3.0/app1.dll
/home/per/dotnet/sdk/3.0.100-preview6-012264/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): error NU5019: File not found: '/home/per/proj/app1/bin/Debug/netcoreapp3.0/app1.runtimeconfig.json'. [/home/per/proj/app1/app1.csproj]

The env is still the same as post above.

A bit surprised such a basic thing passed acceptance tests, even though I know this is a preview? Is there any immediate plans to fix this?

We release our product as a set of packages and need to build native bits on Linux, so we are pretty blocked on this, or need to move built bits from Linux to Windows agents to do the packaging, which is of course something we would rather not want to spend time on.