Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use -NoDefaultExcludes when creating a nuget package

I have a travis build script In that script it packs a nuget package

dotnet pack src/Google.Analytics.SDK.Core --configuration $BUILD_CONFIGURATION --no-restore --no-build --output $NUPKG_DIR /p:NuspecFile=$NUSPEC_PATH

the $NUSPEC_PATH is a .nuspec file.

I am getting the following warning in my build.

/usr/share/dotnet/sdk/2.1.301/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): warning NU5119: File '/home/travis/build/LindaLawton/google-analytics-dotnet-sdk/deploy/.nuspec' 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 [/home/travis/build/LindaLawton/google-analytics-dotnet-sdk/src/Google.Analytics.SDK.Core/Google.Analytics.SDK.Core.csproj] Successfully created package '/home/travis/build/LindaLawton/google-analytics-dotnet-sdk/NuPkg/Daimto.Google.Analytics.Tracker.SDK.1.0.0-beta.nupkg'.

I am having trouble figureing out where it wants me to add this -NoDefaultExcludes

  • I tried adding it as its own command and that failed.
  • I tried adding it to the dotnet pack and that didnt work either
  • I have tried renaming the file to .xml which doesnt work either.
like image 702
DaImTo Avatar asked Jun 29 '18 12:06

DaImTo


2 Answers

Add the tag NoDefaultExcludes to PropertyGroup of the project you are targeting in pack command. Something like this:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <PackageType>Template</PackageType>
        ...
        <NoDefaultExcludes>true</NoDefaultExcludes>
    </PropertyGroup>
</Project>
like image 82
Juan Comandi Avatar answered Oct 13 '22 21:10

Juan Comandi


Set a property called NoPackageAnalysis to true in your csproj file or from the command line pass /p:NoPackageAnalysis=true

like image 43
rohit21agrawal Avatar answered Oct 13 '22 19:10

rohit21agrawal