暂时拒绝了Paket访问

时间:2016-02-02 10:48:00

标签: c# batch-file f#-fake paket

当我尝试打包我的项目的dll时,我遇到了Paket的问题,我只是得到了“Paket失败了:访问路径被拒绝了”,我有以下配置

在VisualStudio的postbuild事件中,我调用bat文件来调用脚本

的build.bat

@ECHO off

cls

SET TargetName=%1
SET BuildMode=%2
SET SolutionDir=%~dp0

rem Get latests version of Paket
"%~dp0.paket\paket.bootstrapper.exe"
IF errorlevel 1 (
    ECHO error on paket.bootstrapper
)

rem Download the dependencies specified by the paket.lock file into the packages/ directory. 
"%~dp0.paket\paket.exe" restore
IF errorlevel 1 (
    ECHO error on paket.restore
)

rem ECHO Starting FAKE build.fsx
"%SolutionDir%packages\FAKE\tools\FAKE.exe" "%SolutionDir%buildPackage.fsx" -ev TargetName %TargetName% -ev BuildMode %BuildMode% -ev SolutionDir "%SolutionDir%

build.fsx

open Fake.AssemblyInfoFile
open System
open Paket

//CommandLineArguments
let TargetName = Environment.GetEnvironmentVariable("TargetName")    
let SolutionDir = Environment.GetEnvironmentVariable("SolutionDir")
let BuildMode = Environment.GetEnvironmentVariable("BuildMode")

//Paths
let AssemblyFilePath = SolutionDir + TargetName + @"\Properties\AssemblyInfo.cs"
let PaketPath = SolutionDir + @".paket\paket.exe"
let PaketOutPath = @"X:\nuget\" + TargetName
let buildDir = SolutionDir + TargetName + @"\bin\Fake\" + BuildMode

//Constants
let constantSolution = SolutionDir + TargetName + @"\" + TargetName + ".csproj"

//Functions
let GetVersion = 
    GetAttributeValue "AssemblyVersion" AssemblyFilePath

//Targets
Target "Clean" (fun _ ->
        Console.WriteLine ("Cleaning up")
        CleanDir buildDir
)

Target "BuildApp" (fun _ ->
    Console.WriteLine("Building application on " + buildDir)
    if BuildMode = "Debug" then MSBuildDebug buildDir "Build" !! constantSolution
                                    |> Log "AppBuild-Output:" 
    else MSBuildRelease buildDir "Build" !! constantSolution
            |>Log "AppBuild-Output"
)

Target "CreatePackage" (fun _ ->
    Pack (fun p ->
        {p with
            Version = GetVersion.Value
            OutputPath = PaketOutPath
            BuildConfig = BuildMode
            ToolPath = PaketPath
            TemplateFile = SolutionDir + TargetName
            BuildPlatform = "x86"
            WorkingDir = buildDir
        })
)

Dependencies
"Clean"
    ==> "BuildApp"
    ==> "CreatePackage"

RunTargetOrDefault "CreatePackage"

我完全迷失在这里,谷歌没有帮助,任何想法为什么paket失败? 在此先感谢,任何想法都会很好。

1 个答案:

答案 0 :(得分:1)

发现问题...在目标“CreatePackage”中,我在字段TemplateFile上使用该文件的路径,不包括文件的实际名称

这是“修复”

Target "CreatePackage" (fun _ ->
    Pack (fun p ->
        {p with
            Version = GetVersion.Value
            OutputPath = PaketOutPath
            BuildConfig = BuildMode
            ToolPath = PaketPath
            TemplateFile = SolutionDir + TargetName + @"\paket.template"
            BuildPlatform = "x86"
            WorkingDir = buildDir
        })
)