-1

I have a nuget package with some dll's included. I have the dll's on content, copy always.

DLL's Copy Always

When I install the nuget package the dll's are not set on copy always. I read about using Install.ps1 (Stackoverflow link). But this doesn't work for nuget version 3.x (See this link: Nuget documentation). The other approch given hear is not clear for me.

The code can be found on Github. And also on Nuget.

This is the file where it is used:

public class CoordinateConverterUtilities
{
#if WIN64
    private const string DllImport = @"Plugins/ETRS89_LAMBERT_UTM_64bits.dll";
#else
    private const string DllImport = @"Plugins/ETRS89_LAMBERT_UTM_32bits.dll";
#endif

    #region Coordinate conversion functions using NGI DLL

    //Import the dll with the functions to calculate lambert coordinates
    [DllImport(DllImport, SetLastError = true, CharSet = CharSet.Auto)]
    public static extern int GeoETRS89ToLambert72(double Xi, double Yi, double Zi, ref double xo, ref double yo, ref double Ho);

    [DllImport(DllImport, SetLastError = true, CharSet = CharSet.Auto)]
    public static extern int Lambert72ToLambert08(double Xi, double Yi, double Zi, ref double xo, ref double yo, ref double Ho);

    [DllImport(DllImport, SetLastError = true, CharSet = CharSet.Auto)]
    public static extern int Lambert72ToGeoETRS89(double Xi, double Yi, double Zi, ref double xo, ref double yo, ref double Ho);

    #endregion
}

Can someone help me or explain this?

Community
  • 1
  • 1
kevingoos
  • 3,785
  • 4
  • 36
  • 63
  • Keeping the package name a secret does not help us help you. There is no compelling reason why the install.ps1 script would not get the job done. Except one, they sometimes need to have VS run elevated. So start VS by right-clicking its shortcut and selecting "Run as Adminstrator" and try to install the package again. With the expectation that your project now has a valid post-build event. If that doesn't help then contact the package author for support. – Hans Passant Feb 22 '17 at 09:40
  • @HansPassant first of all the package is mine so I can adapt it. Second Powershell script support was modified to no longer execute install and uninstall scripts, but init scripts are still executed. See the following link: http://blog.nuget.org/20151008/NuGet-3-What-and-Why.html. – kevingoos Feb 22 '17 at 10:01
  • @HansPassant I also added github and nuget to the question. – kevingoos Feb 22 '17 at 10:01

1 Answers1

1

If you want those dll's to be deployed with the compiled assembly you should put them into lib folder, and not into content.

The ps script should work, but I would follow the standard route and put additional dependencies in lib.

Reference: https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package#from-a-convention-based-working-directory

Alberto Chiesa
  • 7,022
  • 2
  • 26
  • 53
  • 1
    What doesn't work for you? Putting a dll in lib works automatically, provided you create a .nuspec file. This dll must be referenced by your project or not? If yes, lib is the way to go. If not, content and ps script. Edit the question if you need changes on the nuspec. – Alberto Chiesa Feb 22 '17 at 16:20