2014-10-19 28 views
2

我一直在尝试配置我的本地NuGet源代码,以便在那里放置我自己的包。所以我创建了一个文件夹并在Visual Studio中设置路径 - 这很好。本地NuGet源代码+用FAKE创建包

目前我遇到了用FAKE创建包的问题。 nupkg文件被成功创建,但是当我尝试从另一个项目中添加对它的引用时,什么都没有发生(即VS说包已成功添加,但我在“参考”下看不到它)。

我的示例项目具有以下结构:

-- root 
    -- MyProject (project type: F# library) 
    -- MyProject.Test (Xunit) 
    build.bat 
    build.fsx 
    MyProject.nuspec 
    MyProject.sln 

而且我想我的NuGet包包含在MyProject的定义函数(它没有任何额外的dependenties,除了“传统”的人作为FSharp.Core)。 .nuspec文件的内容如下:

<?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>@[email protected]</id> 
    <version>@[email protected]</version> 
    <authors>@[email protected]</authors> 
    <owners>@[email protected]</owners> 
    <summary>@[email protected]</summary> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>@[email protected]</description> 
    <releaseNotes>@[email protected]</releaseNotes> 
    @[email protected] 
    @[email protected] 
    </metadata> 
    <files> 
    <file src="**\*.*" exclude="**\*.pdb;**\*.xml" /> 
    </files> 
</package> 

的build.fsx文件是很长,所以我会贴上它唯一的一块,那就是负责如果有更多的内容是创建包(喊需要):

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 

回答

1

由于您的文件未放入nuget包中的正确目标文件夹,因此nuget不知道要引用它们。

你需要改变你的文件,使他们把要引用到lib文件夹中NuGet包例如dll文件:

<files> 
    <file src="directory\MyProject.dll" target="lib" /> 
</files> 

或FAKE本身:

Nuget(
    { p with 
      Files = [@"directory\MyProject.dll", Some @"lib", None] }) 

(但是如果你想从FAKE来完成,你必须用你的nuspec文件中的files config部分替换为@@[email protected]@

+0

Works fine - 谢谢 :)。 – 2014-10-21 18:57:18