Describe the bug
When using the NuGet package Microsoft.Web.LibraryManager.Build to restore a libman.json file which includes a wildcard in library.files, the build fails with errors. All files matching the wildcard are successfully loaded.
Removing all wildcards and instead listing all files explicitly works just fine.
I've tried to reproduce the issue based on the stack trace with a small C# project. But I don't get any exceptions (see Snippet in Screenshots section).
To Reproduce
Steps to reproduce the behavior:
- Add dependency
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.67" /> to Microsoft.NET.Sdk.Web or Microsoft.NET.Sdk.Razor project
- Add libman.json file with wildcard in files section like
dist/* (see libman.json in Screenshots section)
- Build the project
- See error in Screenshots section
Expected behavior
Support wildcard in NuGet package Microsoft.Web.LibraryManager.Build just like the CLI does. Do not raise build error, if all files have been restored successfully.
Screenshots
libman.json
{
"version": "3.0",
"defaultProvider": "jsdelivr",
"libraries": [
{
"library": "tailwindcss@4.0.14",
"destination": "wwwroot/lib/tailwindcss/",
"files": [
"index.css",
"dist/*"
]
}
]
}
Error on output
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: The "Microsoft.Web.LibraryManager.Build.RestoreTask" task failed unexpectedly.
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: System.ArgumentException: Illegal characters in path.
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Build.RestoreTask.PopulateFilesWritten(IEnumerable`1 results, IHostInteraction hostInteraction)
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Build.RestoreTask.Execute()
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Build.Framework.ITask.Execute()
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
.\3.0.67\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Snippet
// From: https://github.com/aspnet/LibraryManager/blob/bf89ce8604f12f45893ad13f3fe6aaf56c1deed4/src/LibraryManager.Build/RestoreTask.cs#L140C1-L162C6
// Expected values for my restore
var workingDirectory = @"C:\temp\demo\subdir\project\";
var destinationPath = "wwwroot/lib/tailwindcss/";
var file = "dist/*";
var absolutePath = Path.Combine(workingDirectory, destinationPath, file);
Console.WriteLine("Absolute Path " + absolutePath);
var absolute = new FileInfo(absolutePath);
Console.WriteLine("Absolute " + absolute);
Console.WriteLine("Exists " + absolute.Exists);
Console.WriteLine("Fullname " + absolute.FullName);
Snippet Output
Absolute Path C:\temp\demo\subdir\project\wwwroot/lib/tailwindcss/dist/*
Absolute C:\temp\demo\subdir\project\wwwroot/lib/tailwindcss/dist/*
Exists False
Fullname C:\temp\demo\subdir\project\wwwroot\lib\tailwindcss\dist\*
Additional context
.NET 9 (Microsoft.NET.Sdk.Web or Microsoft.NET.Sdk.Razor project)
Visual Studio 17.13.4
Microsoft Library Manager 3.0.64.3734
Microsoft.Web.LibraryManager.Build 3.0.67
Describe the bug
When using the NuGet package Microsoft.Web.LibraryManager.Build to restore a
libman.jsonfile which includes a wildcard inlibrary.files, the build fails with errors. All files matching the wildcard are successfully loaded.Removing all wildcards and instead listing all files explicitly works just fine.
I've tried to reproduce the issue based on the stack trace with a small C# project. But I don't get any exceptions (see Snippet in Screenshots section).
To Reproduce
Steps to reproduce the behavior:
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.67" />toMicrosoft.NET.Sdk.WeborMicrosoft.NET.Sdk.Razorprojectdist/*(seelibman.jsonin Screenshots section)Expected behavior
Support wildcard in NuGet package
Microsoft.Web.LibraryManager.Buildjust like the CLI does. Do not raise build error, if all files have been restored successfully.Screenshots
libman.json{ "version": "3.0", "defaultProvider": "jsdelivr", "libraries": [ { "library": "tailwindcss@4.0.14", "destination": "wwwroot/lib/tailwindcss/", "files": [ "index.css", "dist/*" ] } ] }Error on output
Snippet
Snippet Output
Additional context
.NET 9 (Microsoft.NET.Sdk.Web or Microsoft.NET.Sdk.Razor project)
Visual Studio 17.13.4
Microsoft Library Manager 3.0.64.3734
Microsoft.Web.LibraryManager.Build 3.0.67