In this case, I'm running nuget pack directly against the nuspec as there
is no csproj for this particular package (just some config files).

Also, contentFiles only works with the newer "SDK" style csproj.

Another example that could be worth examining is the
JavaScriptEngineSwitcher project - this produces a number of public NuGet
files that include native binaries.

https://github.com/Taritsyn/JavaScriptEngineSwitcher
https://github.com/Taritsyn/JavaScriptEngineSwitcher/tree/master/src/JavaScriptEngineSwitcher.V8.Native.win-x64

Dave

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

> That doesn't work either. The dll arrives in the target root, simply
> because it's source content (I think). The other elements seem to have no
> effect at all on which files are packaged or delivered. If the dll is
> content None that it's never packaged
>
> How are you running nuget pack? I'm doing it against the csproj file, not
> against the nuspec file.
>
>  -- *Greg*
>
> On Tue, 14 Apr 2020 at 15:39, David Gardiner <[email protected]>
> wrote:
>
>> 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