3

I have a NET Library project that targets net462 that includes a Microsoft.NET.SDK.Functions Nuget package. Problem is that when I pack my project into a Nuget library, it all succeeds (clean,restore,build,pack) except no .nupkg is created. If I comment out relevant code and get rid of the Nuget reference, a nupkg file is produced when I pack it.

I seem to be hitting this issue: IN GITHUB maybe?

The package in question - https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions

My direct question is - Is this a possible feature? Can you prevent your packages from being packed into Nugets? How would I know. Or in any other words, is this situation (the one described in the GitHub issue) even possible? What could be going wrong? Thanks!

jn1kk
  • 5,012
  • 2
  • 45
  • 72

2 Answers2

1

I just ran into this same problem where dotnet pack was not producing packages for .csproj files that use the Microsoft.Functions.SDK package.

dotnet pack allows you to provide MSBuild parameters that are respected, even if it doesn't occur in their docs, so you can force a nuget package to be generated by doing something like this on the command line:

dotnet pack --configuration Release -property:IsPackable=true

The functions SDK appears to have some code in it I've not spent the time to track down that forces that IsPackable flag to false, regardless of the value in the .csproj.

If you're struggling with these things in the future, you can look at the diagnostics of the dotnet command by appending -v=d (setting Verbosity to Debug) to your command line commands.

DavidWhitney
  • 4,290
  • 4
  • 24
  • 30
0

Step 1 :open the project folder

Step 2 : open cmd

Step 5 : you should see a cmd that point to your project not solution directory

Step 6 : copy and past the flowing commands

    PowerShell -Command "Get-ChildItem $dir | Where { $_.Name -match '.csproj'} | Select -Expand Name | out-file -encoding ASCII projectname"

    SET /p projectname=<projectname

    PowerShell -Command "(Get-Content -path ..\packages\Microsoft.NET.Sdk.Functions.1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets -Raw) -replace 'DependsOnTargets="""RunResolvePublishAssemblies"""', '' | Set-Content -Path  ..\packages\Microsoft.NET.Sdk.Functions.1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets"

    SET MSBuild_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

    SET PATH=%MSBuild_PATH%;%PATH%

    MSbuild %projectname% /t:Clean;Rebuild /p:Configuration=Release

    PowerShell -Command "Get-ChildItem -Path .\bin\Release\bin -Recurse | Copy-Item -Destination .\bin\Release "

    PowerShell -Command "if(!(Test-Path -Path 'nuget.exe')){(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe','nuget.exe')}"

    NuGet.exe pack %projectname% -Prop Configuration=Release -MSBuildPath "%MSBuild_PATH%"

    start .

Step 7 : you should find your nupkg file

Note : i used vs 2017 with flowing steps

create a new project

install Microsoft.NET.Sdk.Functions

Mohamed Elrashid
  • 8,125
  • 6
  • 31
  • 46