diff --git a/src/Paket.Core/PackageMetaData.fs b/src/Paket.Core/PackageMetaData.fs index 2e187c7e55..ed374c1c29 100644 --- a/src/Paket.Core/PackageMetaData.fs +++ b/src/Paket.Core/PackageMetaData.fs @@ -67,24 +67,26 @@ let getDescription attributes = | Description d -> Some d | _ -> None) -let readAssembly buildConfig buildPlatform (projectFile : ProjectFile) = - let fileName = - FileInfo( - Path.Combine - (Path.GetDirectoryName projectFile.FileName, projectFile.GetOutputDirectory buildConfig buildPlatform, - projectFile.GetAssemblyName()) - |> normalizePath) - - traceVerbose <| sprintf "Loading assembly metadata for %s" fileName.FullName +let readAssembly fileName = + traceVerbose <| sprintf "Loading assembly metadata for %s" fileName let assemblyReader = ProviderImplementation.AssemblyReader.ILModuleReaderAfterReadingAllBytes( - fileName.FullName, + fileName, ProviderImplementation.AssemblyReader.mkILGlobals ProviderImplementation.AssemblyReader.ecmaMscorlibScopeRef, true) let versionFromAssembly = assemblyReader.ILModuleDef.ManifestOfAssembly.Version let id = assemblyReader.ILModuleDef.ManifestOfAssembly.Name - assemblyReader,id,versionFromAssembly,fileName.FullName + assemblyReader,id,versionFromAssembly,fileName + + +let readAssemblyFromProjFile buildConfig buildPlatform (projectFile : ProjectFile) = + FileInfo( + Path.Combine + (Path.GetDirectoryName projectFile.FileName, projectFile.GetOutputDirectory buildConfig buildPlatform, + projectFile.GetAssemblyName()) + |> normalizePath).FullName + |> readAssembly let loadAssemblyAttributes (assemblyReader:ProviderImplementation.AssemblyReader.CacheValue) = [for inp in assemblyReader.ILModuleDef.ManifestOfAssembly.CustomAttrs.Elements do diff --git a/src/Paket.Core/PackageProcess.fs b/src/Paket.Core/PackageProcess.fs index eca859f2d6..a5e6149fde 100644 --- a/src/Paket.Core/PackageProcess.fs +++ b/src/Paket.Core/PackageProcess.fs @@ -10,15 +10,15 @@ open System.Collections.Generic open Paket.PackageMetaData open Chessie.ErrorHandling -let private merge buildConfig buildPlatform version projectFile templateFile = +let private merge buildConfig buildPlatform versionFromAssembly projectFile templateFile = let withVersion = - match version with + match versionFromAssembly with | None -> templateFile | Some v -> templateFile |> TemplateFile.setVersion v match withVersion with | { Contents = ProjectInfo(md, opt) } -> - let assemblyReader,id,versionFromAssembly,assemblyFileName = readAssembly buildConfig buildPlatform projectFile + let assemblyReader,id,versionFromAssembly,assemblyFileName = readAssemblyFromProjFile buildConfig buildPlatform projectFile let attribs = loadAssemblyAttributes assemblyReader let mergedOpt = @@ -37,7 +37,7 @@ let private merge buildConfig buildPlatform version projectFile templateFile = let merged = { Id = md.Id - Version = md.Version ++ getVersion version attribs + Version = md.Version ++ getVersion versionFromAssembly attribs Authors = md.Authors ++ getAuthors attribs Description = md.Description ++ getDescription attribs Symbols = md.Symbols } diff --git a/tests/Paket.Tests/PackageProcessSpecs.fs b/tests/Paket.Tests/PackageProcessSpecs.fs index 44fd343cb9..38c10fb596 100644 --- a/tests/Paket.Tests/PackageProcessSpecs.fs +++ b/tests/Paket.Tests/PackageProcessSpecs.fs @@ -18,15 +18,14 @@ let ``Loading assembly metadata works``() = failwithf "%s does not exist." fileName let projFile = - Path.Combine(workingDir, "..", "..", "Paket.Tests.fsproj") - |> normalizePath + fileName |> ProjectFile.LoadFromFile let config = if workingDir.Contains "Debug" then "Debug" else "Release" - let assemblyReader,id,versionFromAssembly,fileName = PackageMetaData.readAssembly config "" projFile + let assemblyReader,id,versionFromAssembly,fileName = PackageMetaData.readAssemblyFromProjFile config "" projFile id |> shouldEqual "Paket.Tests" let attribs = PackageMetaData.loadAssemblyAttributes assemblyReader