From 4999ab6bcac49cc8a3d679182ba1929966b34424 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 17 Nov 2015 09:34:59 +0100 Subject: [PATCH] Detect AssemblyName from project file name if empty - fixes #1234 --- RELEASE_NOTES.md | 3 + .../Paket.IntegrationTests/PackSpecs.fs | 18 ++++++ .../Paket.IntegrationTests.fsproj | 1 + .../before/PaketBug.sln | 22 +++++++ .../before/PaketBug/Class1.cs | 12 ++++ .../before/PaketBug/PaketBug.csprojtemplate | 61 +++++++++++++++++++ .../PaketBug/Properties/AssemblyInfo.cs | 36 +++++++++++ .../before/PaketBug/paket.template | 4 ++ .../before/paket.dependencies | 1 + .../before/paket.lock | 1 + src/Paket.Core/ProjectFile.fs | 6 ++ 11 files changed, 165 insertions(+) create mode 100644 integrationtests/Paket.IntegrationTests/PackSpecs.fs create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug.sln create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Class1.cs create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/PaketBug.csprojtemplate create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Properties/AssemblyInfo.cs create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/paket.template create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/paket.dependencies create mode 100644 integrationtests/scenarios/i001234-missing-assemblyname/before/paket.lock diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index fd39385ee6..a27c7a96f3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 2.25.8 - 17.11.2015 +* BUGFIX: Detect AssemblyName from project file name if empty - https://github.com/fsprojects/Paket/issues/1234 + #### 2.25.7 - 17.11.2015 * BUGFIX: Fixed issue with V3 feeds doing api requests even when the paket.lock is fully specified - https://github.com/fsprojects/Paket/pull/1231 * USABILITY: Always write nomalized version into lock file to keep the lockfile as stable as possible diff --git a/integrationtests/Paket.IntegrationTests/PackSpecs.fs b/integrationtests/Paket.IntegrationTests/PackSpecs.fs new file mode 100644 index 0000000000..2011ed9854 --- /dev/null +++ b/integrationtests/Paket.IntegrationTests/PackSpecs.fs @@ -0,0 +1,18 @@ +module Paket.IntegrationTests.PackSpecs + +open Fake +open System +open NUnit.Framework +open FsUnit +open System +open System.IO +open System.Diagnostics + +[] +let ``#1234 empty assembly name``() = + let outPath = Path.Combine(scenarioTempPath "i001234-missing-assemblyname","out") + try + paket ("pack -v output \"" + outPath + "\"") "i001234-missing-assemblyname" |> ignore + failwith "Expected an exeption" + with + | exn when exn.Message.Contains("PaketBug.dll") -> () \ No newline at end of file diff --git a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj b/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj index cc8dc21428..aba1815a78 100644 --- a/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj +++ b/integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj @@ -103,6 +103,7 @@ + diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug.sln b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug.sln new file mode 100644 index 0000000000..24ba390073 --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaketBug", "PaketBug\PaketBug.csproj", "{5B41A984-0C88-41C7-8669-41D298D0E450}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5B41A984-0C88-41C7-8669-41D298D0E450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B41A984-0C88-41C7-8669-41D298D0E450}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B41A984-0C88-41C7-8669-41D298D0E450}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B41A984-0C88-41C7-8669-41D298D0E450}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Class1.cs b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Class1.cs new file mode 100644 index 0000000000..e32a964559 --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Class1.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PaketBug +{ + public class Class1 + { + } +} diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/PaketBug.csprojtemplate b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/PaketBug.csprojtemplate new file mode 100644 index 0000000000..6c7fb7f1e3 --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/PaketBug.csprojtemplate @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + 5b41a984-0c88-41c7-8669-41d298d0e450 + Library + Properties + PaketBug + + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Properties/AssemblyInfo.cs b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..53a060718b --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PaketBug")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PaketBug")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5b41a984-0c88-41c7-8669-41d298d0e450")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/paket.template b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/paket.template new file mode 100644 index 0000000000..732a71cf78 --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/PaketBug/paket.template @@ -0,0 +1,4 @@ +type project + +description + Silly empty demo project diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.dependencies b/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.dependencies new file mode 100644 index 0000000000..c78b16de6a --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.dependencies @@ -0,0 +1 @@ +source https://nuget.org/api/v2 diff --git a/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.lock b/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.lock new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/integrationtests/scenarios/i001234-missing-assemblyname/before/paket.lock @@ -0,0 +1 @@ + diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index 33ff31cf36..6bc108833d 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -987,6 +987,12 @@ type ProjectFile = | assemblyName::_ -> traceWarnfn "Found multiple AssemblyName nodes in file %s, using first" this.FileName assemblyName.InnerText + |> fun assemblyName -> + if String.IsNullOrWhiteSpace assemblyName then + let fi = FileInfo this.FileName + fi.Name.Replace(fi.Extension,"") + else assemblyName + sprintf "%s.%s" assemblyName (this.OutputType |> function ProjectOutputType.Library -> "dll" | ProjectOutputType.Exe -> "exe") static member LoadFromStream(fullName:string, stream:Stream) =