Reputation: 2248
I've been trying to configure my local NuGet source so as to put there my own packages. So I created a folder and set up the path in Visual Studio - this works fine.
Currently I've got a problem with creating a package with FAKE. The nupkg file gets successfully created, but when I try to add a reference to it from another project, nothing happens (i.e. VS says the package was successfully added, but I can't see it under the "References").
My example project has the following structure:
-- root
-- MyProject (project type: F# library)
-- MyProject.Test (Xunit)
build.bat
build.fsx
MyProject.nuspec
MyProject.sln
And I'd like my NuGet package to contain functions defined in MyProject (It doesn't have any additional dependenties, apart from the "traditional" ones as FSharp.Core). The content of .nuspec file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>@project@</id>
<version>@build.number@</version>
<authors>@authors@</authors>
<owners>@authors@</owners>
<summary>@summary@</summary>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>@description@</description>
<releaseNotes>@releaseNotes@</releaseNotes>
@dependencies@
@references@
</metadata>
<files>
<file src="**\*.*" exclude="**\*.pdb;**\*.xml" />
</files>
</package>
The build.fsx file is quite long, so I'll paste only piece of it, that is responsible for creating a package (shout if more content is needed):
let buildDir = @".\build\"
let testDir = @".\test\"
let deployDir = @".\deploy\"
let nugetDir = @".\nuget\"
Target "CreateNuget" (fun _ ->
XCopy buildDir nugetDir
"MyProject.nuspec"
|> NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = projectDescription
Version = version
NoPackageAnalysis = true
OutputPath = nugetDir
})
)
Target "Publish" (fun _ ->
!! (nugetDir + "*.nupkg")
|> Copy deployDir
Upvotes: 2
Views: 1137
Reputation: 711
Because your files aren't put into the correct target folder in the nuget package, nuget doesn't know you want to reference them.
You need to change your files so that they put the dlls you want to reference into a lib
folder in your nuget package for example:
<files>
<file src="directory\MyProject.dll" target="lib" />
</files>
or from FAKE itself:
Nuget(
{ p with
Files = [@"directory\MyProject.dll", Some @"lib", None] })
(but if you want to do it from FAKE you'll have to replace the files
config section in your nuspec file with @@files@@
.
Upvotes: 1