diff --git a/src/Cake.Common.Tests/Fixtures/AssemblyInfoParserFixture.cs b/src/Cake.Common.Tests/Fixtures/AssemblyInfoParserFixture.cs index 11a125000f..fab9b36477 100644 --- a/src/Cake.Common.Tests/Fixtures/AssemblyInfoParserFixture.cs +++ b/src/Cake.Common.Tests/Fixtures/AssemblyInfoParserFixture.cs @@ -43,6 +43,11 @@ public AssemblyInfoParserFixture() CreateAssemblyInfo = true; } + public void WithAssemblyInfoContents(string assemblyInfoContents) + { + FileSystem.CreateFile("/Working/output.cs").SetContent(assemblyInfoContents); + } + public AssemblyInfoParseResult Parse() { if (CreateAssemblyInfo && Path != null) diff --git a/src/Cake.Common.Tests/Properties/Resources.Designer.cs b/src/Cake.Common.Tests/Properties/Resources.Designer.cs index d217436857..6e6a4f02e3 100644 --- a/src/Cake.Common.Tests/Properties/Resources.Designer.cs +++ b/src/Cake.Common.Tests/Properties/Resources.Designer.cs @@ -257,6 +257,26 @@ internal static string InspectCodeReportWithViolations { } } + /// + /// Looks up a localized string similar to using System.Reflection; + ///using System.Runtime.CompilerServices; + /// + ///// Information about this assembly is defined by the following attributes. + ///// Change them to the values specific to your project. + /// + ///[assembly: AssemblyTitle ("MonoDevelopAssemblyTitle")] + ///[assembly: AssemblyDescription ("MonoDevelopAssemblyDescription")] + ///[assembly: AssemblyConfiguration ("MonoDevelopConfiguration")] + ///[assembly: AssemblyCompany ("MonoDevelopCompany")] + ///[assembly: AssemblyProduct ("MonoDevelopProduct")] + ///[assembly: Assembl [rest of string was truncated]";. + /// + internal static string MonoDevelopAssemblyInfo { + get { + return ResourceManager.GetString("MonoDevelopAssemblyInfo", resourceCulture); + } + } + /// /// Looks up a localized string similar to <?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"> @@ -409,6 +429,26 @@ internal static string Nuspec_ProjectFile { } } + /// + /// Looks up a localized string similar to using System.Reflection; + ///using System.Runtime.CompilerServices; + /// + ///// Information about this assembly is defined by the following attributes. + ///// Change them to the values specific to your project. + /// + ///[assembly: AssemblyTitle("VisualStudioAssemblyTitle")] + ///[assembly: AssemblyDescription("VisualStudioAssemblyDescription")] + ///[assembly: AssemblyConfiguration("VisualStudioConfiguration")] + ///[assembly: AssemblyCompany("VisualStudioCompany")] + ///[assembly: AssemblyProduct("VisualStudioProduct")] + ///[assembly: Assembl [rest of string was truncated]";. + /// + internal static string VisualStudioAssemblyInfo { + get { + return ResourceManager.GetString("VisualStudioAssemblyInfo", resourceCulture); + } + } + /// /// Looks up a localized string similar to <?xml version="1.0"?> ///<doc> diff --git a/src/Cake.Common.Tests/Properties/Resources.resx b/src/Cake.Common.Tests/Properties/Resources.resx index 46085bf28f..4ca8c85492 100644 --- a/src/Cake.Common.Tests/Properties/Resources.resx +++ b/src/Cake.Common.Tests/Properties/Resources.resx @@ -768,4 +768,60 @@ Line #3]]></releaseNotes> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> </Project> + + using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("MonoDevelopAssemblyTitle")] +[assembly: AssemblyDescription ("MonoDevelopAssemblyDescription")] +[assembly: AssemblyConfiguration ("MonoDevelopConfiguration")] +[assembly: AssemblyCompany ("MonoDevelopCompany")] +[assembly: AssemblyProduct ("MonoDevelopProduct")] +[assembly: AssemblyCopyright ("MonoDevelopCopyright")] +[assembly: AssemblyTrademark ("MonoDevelopTrademark")] +[assembly: AssemblyCulture ("en-US")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.14")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + + + using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("VisualStudioAssemblyTitle")] +[assembly: AssemblyDescription("VisualStudioAssemblyDescription")] +[assembly: AssemblyConfiguration("VisualStudioConfiguration")] +[assembly: AssemblyCompany("VisualStudioCompany")] +[assembly: AssemblyProduct("VisualStudioProduct")] +[assembly: AssemblyCopyright("VisualStudioCopyright")] +[assembly: AssemblyTrademark("VisualStudioTrademark")] +[assembly: AssemblyCulture("en-US")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.13")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + \ No newline at end of file diff --git a/src/Cake.Common.Tests/Unit/Solution/Project/Properties/AssemblyInfoParserTests.cs b/src/Cake.Common.Tests/Unit/Solution/Project/Properties/AssemblyInfoParserTests.cs index dd54ea7089..c95ac362c5 100644 --- a/src/Cake.Common.Tests/Unit/Solution/Project/Properties/AssemblyInfoParserTests.cs +++ b/src/Cake.Common.Tests/Unit/Solution/Project/Properties/AssemblyInfoParserTests.cs @@ -2,6 +2,7 @@ using System.Linq; using Cake.Common.Solution.Project.Properties; using Cake.Common.Tests.Fixtures; +using Cake.Common.Tests.Properties; using Cake.Core; using Cake.Core.IO; using NSubstitute; @@ -305,6 +306,48 @@ public void Should_Read_AssemblyVersion(string value, string expected) // Then Assert.Equal(expected, result.AssemblyVersion); } + + [Fact] + public void Should_Correctly_Parse_VisualStudio_AssemblyInfo_File() + { + // Given + var fixture = new AssemblyInfoParserFixture(); + fixture.CreateAssemblyInfo = false; + fixture.WithAssemblyInfoContents(Resources.VisualStudioAssemblyInfo.NormalizeLineEndings()); + + // When + var result = fixture.Parse(); + + // Then + Assert.Equal(result.Title, "VisualStudioAssemblyTitle"); + Assert.Equal(result.Description, "VisualStudioAssemblyDescription"); + Assert.Equal(result.Configuration, "VisualStudioConfiguration"); + Assert.Equal(result.Company, "VisualStudioCompany"); + Assert.Equal(result.Product, "VisualStudioProduct"); + Assert.Equal(result.Copyright, "VisualStudioCopyright"); + Assert.Equal(result.Trademark, "VisualStudioTrademark"); + } + + [Fact] + public void Should_Correctly_Parse_MonoDevelop_AssemblyInfo_File() + { + // Given + var fixture = new AssemblyInfoParserFixture(); + fixture.CreateAssemblyInfo = false; + fixture.WithAssemblyInfoContents(Resources.MonoDevelopAssemblyInfo.NormalizeLineEndings()); + + // When + var result = fixture.Parse(); + + // Then + Assert.Equal(result.Title, "MonoDevelopAssemblyTitle"); + Assert.Equal(result.Description, "MonoDevelopAssemblyDescription"); + Assert.Equal(result.Configuration, "MonoDevelopConfiguration"); + Assert.Equal(result.Company, "MonoDevelopCompany"); + Assert.Equal(result.Product, "MonoDevelopProduct"); + Assert.Equal(result.Copyright, "MonoDevelopCopyright"); + Assert.Equal(result.Trademark, "MonoDevelopTrademark"); + } } } } \ No newline at end of file diff --git a/src/Cake.Common/Solution/Project/Properties/AssemblyInfoParser.cs b/src/Cake.Common/Solution/Project/Properties/AssemblyInfoParser.cs index 90f76804b7..16f1606f67 100644 --- a/src/Cake.Common/Solution/Project/Properties/AssemblyInfoParser.cs +++ b/src/Cake.Common/Solution/Project/Properties/AssemblyInfoParser.cs @@ -14,8 +14,8 @@ namespace Cake.Common.Solution.Project.Properties /// public sealed class AssemblyInfoParser { - private const string NonQuotedPattern = @"^\s*\[assembly: {0}\((?.*)\)"; - private const string QuotedPattern = @"^\s*\[assembly: {0}\(""(?.*)""\)"; + private const string NonQuotedPattern = @"^\s*\[assembly: {0} ?\((?.*)\)"; + private const string QuotedPattern = @"^\s*\[assembly: {0} ?\(""(?.*)""\)"; private const string DefaultVersion = "1.0.0.0"; private readonly IFileSystem _fileSystem;