question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
miyconstcommented, Jul 7, 2019

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
1reaction
miyconstcommented, Jun 28, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet pack recently failing
In our case, the error was due to multiple dependent nuget packages that all contained a .targets file with an element as this...
Read more >
Cannot install .NET Core on Ubuntu Bionic Beaver
I'm currently trying to install .NET Core on Ubuntu 18.04 following these instructions. But I always get the following message: me@mine-Ubuntu ...
Read more >
dotnet pack command - .NET CLI
The dotnet pack command creates NuGet packages for your .NET project. ... The build can also fail if there is a locked file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found