PowerShell / PowerShell/PSResourceGet

Set or expose the NoDefaultExcludes nuget parameter in Publish-Module

Open
#625 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-nupkg Area-Publish feature_request
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Summary of the new feature / enhancement

nuget pack (and by transition dotnet pack and Publish-Module) have a default behaviour of ignoring *.nuspec files and .* files and folders. As a result, when publishing PowerShell modules those files also get ignored, which can get in the way depending of what your workflow is (in my case, I'm trying to ship a default ExifTool configuration file).

This can be overriden in nuget and dotnet pack with the CLI switch / csproj property NoDefaultExcludes. The way Publish-Module works though, there is no way to override this, as the module creates a temporary csproj file which the module user has no control over.

It would be nice to set or at least expose this switch in the Publish-Module Cmdlet.

More info:
The verbose logging from Publish-Module when the folder contains a filtered file:

VERBOSE:        C:\Program Files\dotnet\sdk\6.0.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): warning NU5119: File 'C:\Users\xxx\AppData\Local\Temp\222345117\GFK.Image\ExifTool\.ExifTool_config' was
not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline [C:\Users\xxx\AppData\Local\Temp\cba5a149-c53d-420c-9
6ff-bb9c4a63df02\Temp.csproj]
Proposed technical implementation details (optional)

I was able to publish a module including those files by modifying the PowerShellGet module on my local environment myself as follows (specifically the <NoDefaultExcludes>true</NoDefaultExcludes> bit). Feels like it would just be a matter of condtionally control this with a Cmdlet switch parameter.

$CsprojContent = @"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <AssemblyName>NotUsed</AssemblyName>
    <Description>Temp project used for creating nupkg file.</Description>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <IsPackable>true</IsPackable>
    <NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>
</Project>
"@

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Publish-Module cmdlet and the temporary csproj content described in the issue, then trace how cmdlet parameters are passed into that project. The work is done when Publish-Module can conditionally expose or set NoDefaultExcludes and package files such as .ExifTool_config without the default exclusion warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.