Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core 2.0 "Generate Nuget package on build" issue with Post-build events

The new .NET Core 2.0 projects provide and easy and convenient way to create Nuget Package from the project output. Just click on the "Generate Nuget package on build" check box and it is done. enter image description here It works fine but I have an issue with Post-build events. I want to copy all of the packages from a solution after each build to a specific folder. So I use the "Post-build event command line" with a script:

xcopy "$(ProjectDir)$(OutDir)..*.nupkg" "$(SolutionDir)..\WebServicePracticesNuget\" /Y /I

And sometimes it works fine sometimes not at all. So far my investigation concluded that the Nuget package creation is not part of the build process itself. So the script (sometimes) will triggered before the package was generated and it is unpredictable. My solution is to add some delay. Unfortunately "timeout x" is not working with Post-build events. So I used the fallback option:

ping 127.0.0.1 -n 4 > NUL

Which makes it almost reliable (~95%) but I think it is "poor man's" solution. And looks ridiculous in a Post-build event script. I have already reported this issue to the VS team. But not much comments or solution so far.

So my question is: does anybody have the same issue? Or any idea for a better solution then I have now? Thanks.

like image 650
Major Avatar asked Nov 30 '17 15:11

Major


People also ask

How do I reference an existing NuGet package from a new project?

NET Core project. After you install a NuGet package, you can then make a reference to it in your code with the using <namespace> statement, where <namespace> is the name of package you're using. After you've made a reference, you can then call the package through its API.

What is Nuspec file?

nuspec file is an XML manifest that contains package metadata. This manifest is used both to build the package and to provide information to consumers. The manifest is always included in a package. In this topic: General form and schema.


1 Answers

You can configure msbuild task order inside the project file.

like image 87
Roman Patutin Avatar answered Oct 07 '22 13:10

Roman Patutin