Daily Usage Issues

NuGet2.5 native assemblies

Started by AlSki on 5,906 views

For a while now we've been trying at work to get rid of the last non-packaged dependencies for our applications. We already used NuGet for std things, e.g. nunit.framework, specflow, moq, should etc. and our own internal libraries but we just had some unmanaged dlls that we couldn't get around. Now we can package these up and use another "new in 2.5" feature, import props and targets, to automatically copy our unmanaged dlls over to the bin/debug directory. This means that it all works nicely under F5, and also under Resharpers test runner, but not under NCrunch.

When you are using NCrunch you also need to configure Additional files to include to ..\packages\xxxx.1.0.17038\lib\native. Unfortunately this needs manually updating should you refresh the NuGet package to a later version.

I had a thought though, just as NCrunch already allows you to call the post build step, I wonder if you would consider letting us specify a some additional msbuild targets to run too. That way the imported packages can still be called so our test dependencies are handled, and NCrucnh can still warn us that we are slowing down the build by calling these additional targets :-).

What do you think?

It's interesting that NCrunch isn't picking up the native assemblies using its normal reference resolution. Is it that these assemblies are co-located with other files needed for them in order to run? A lower maintenance but more expensive (performance-wise) way to handle this would be to include the entire Nuget packages directory in your additional files to include (i.e. '..\packages\**.*'). This means that updating versions wouldn't require the extra manual step, although your project workspaces would become much bigger to house all the additional files ... which means the engine would take a bit longer to spin up.

It certainly is possible with the current version of NCrunch to run special build steps coded into the project files. You can do this with the 'BeforeBuild' and 'AfterBuild' targets that exist in the default .csproj file template. If you want them only to run under NCrunch, you can make these steps conditional. For example:

<Target Name="BeforeBuild" Condition="$(NCrunch) == '1'">
... do funky file copying here ...
</Target>
<Target Name="AfterBuild" Condition="$(NCrunch) == '1'">
... do funky file copying here ...
</Target>

You can also make Import declarations conditional:

<Import Project="..\build\MyCustomNCrunchBuild.targets" Condition="$(NCrunch) == '1'" />

Post a reply

Log in to reply.