The buildAction attribute controls what kind of action - so you'd set that
to None. Pretty sure CopyIfNewer isn't possible in nuspec (unfortunately) -
just set copyToOutput to true instead. (There are ways around this using a
.targets files, but I wouldn't worry about that to start with).

So given the following files in the current directory:

blah.dll
mypackage.nuspec

and the nuspec has something like:

    <contentFiles>
      <files include="**\*.*" buildAction="None" copyToOutput="yes" />
    </contentFiles>
  </metadata>
  <files>
    <file src="*.dll" target="contentFiles\any\any\"/>
  </files>

I think that should do the trick (just typing this in, not tested)

Also, when you're testing, either keep revving the version number each
time, or make sure you're deleting the previous copy of the nupkg file from
your local cache (%USERPROFILE%\.nuget\packages), otherwise it will keep
using the cached copy.

On Tue, 14 Apr 2020 at 14:17, Greg Keogh <[email protected]> wrote:

> Hi Dave, thanks for that sample. Sadly I can't get it to work. I've tried
> hundreds of combinations of <files> and <contentFiles> elements with
> different paths and names and slashes, I've created different contentFiles
> folder structures, I've set files as build Content and None. Mostly I get
> no content files in the package, and if I set sources files to build
> Content then they go into the package but are installed deep inside useless
> folder structures without the CopyIfNewer that I desire.
>
> The config files in your sample, what is their action in the source
> project, None or Content?
>
> I just want to deliver a single native DLL file into the root of the
> target project and set it to action None and CopyIfNewer.
>
> So I'm up to 6 or 7 hours now and haven't even got anything even vaguely
> hopeful to happen. I have studied the content files
> <https://docs.microsoft.com/en-us/nuget/reference/nuspec#including-content-files>
> section of the nuspec documentation, but I think it was written by an alien
> or mentally ill person (or both), and it needs a complete rewrite. Even the
> samples are nonsensical.
>
> *Greg K*
>

Reply via email to