Selaa lähdekoodia

Merge pull request #155 from js6pak/cake

Update cake script to use msbuild instead of AssemblyInfo.cs
Geoffrey Horsington 4 vuotta sitten
vanhempi
commit
8c856b9cce

+ 0 - 4
BepInEx.Bootstrap/BepInEx.Bootstrap.csproj

@@ -7,10 +7,6 @@
     <OutputPath>..\bin\patcher\</OutputPath>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\BepInEx.Core\BepInEx.Core.csproj" />

+ 0 - 4
BepInEx.Core/BepInEx.Core.csproj

@@ -7,10 +7,6 @@
     <LangVersion>8</LangVersion>
     <Description>Unity plugin injection framework</Description>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>

+ 0 - 10
BepInEx.IL2CPP/BepInEx.IL2CPP.csproj

@@ -7,10 +7,6 @@
     <OutputPath>..\bin\IL2CPP\</OutputPath>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>portable</DebugType>
@@ -53,11 +49,5 @@
     <PackageReference Include="Iced" Version="1.6.0" />
     <PackageReference Include="MonoMod.RuntimeDetour" Version="20.11.5.1" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
   <Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
 </Project>

+ 0 - 10
BepInEx.NetLauncher/BepInEx.NetLauncher.csproj

@@ -7,10 +7,6 @@
     <Product>BepInEx.NetLauncher</Product>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>full</DebugType>
@@ -28,11 +24,5 @@
   <ItemGroup>
     <PackageReference Include="HarmonyX" Version="2.1.1" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
   <Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
 </Project>

+ 0 - 10
BepInEx.Patcher/BepInEx.Patcher.csproj

@@ -11,10 +11,6 @@
     <LangVersion>8</LangVersion>
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup>
     <StartupObject>BepInEx.Patcher.Program</StartupObject>
@@ -39,11 +35,5 @@
   <ItemGroup>
     <EmbeddedResource Include="..\bin\patcher\BepInEx.Bootstrap.dll" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
   <Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
 </Project>

+ 0 - 4
BepInEx.Preloader.Core/BepInEx.Preloader.Core.csproj

@@ -6,10 +6,6 @@
     <OutputPath>..\bin\</OutputPath>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>full</DebugType>

+ 0 - 10
BepInEx.Preloader.Unity/BepInEx.Preloader.Unity.csproj

@@ -6,10 +6,6 @@
     <OutputPath>..\bin\</OutputPath>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>full</DebugType>
@@ -25,11 +21,5 @@
   <ItemGroup>
     <PackageReference Include="HarmonyX" Version="2.1.1" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
   <Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
 </Project>

+ 0 - 8
BepInEx.Shared/AssemblyInfo.cs

@@ -1,8 +0,0 @@
-using System.Reflection;
-// ReSharper disable once RedundantUsingDirective
-using BepInEx.Shared;
-
-[assembly: AssemblyCopyright("Copyright © 2020 BepInEx Team")]
-[assembly: AssemblyVersion(VersionInfo.VERSION)]
-[assembly: AssemblyFileVersion(VersionInfo.VERSION)]
-[assembly: AssemblyInformationalVersion(VersionInfo.VERSION)]

+ 8 - 2
BepInEx.Shared/BepInEx.Shared.projitems

@@ -4,13 +4,19 @@
     <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
     <HasSharedItems>true</HasSharedItems>
     <SharedGUID>E312EFD4-47ED-4DCE-B279-6B0EE314989F</SharedGUID>
+    <Copyright>Copyright © 2020 BepInEx Team</Copyright>
+    <Version>6.0.0</Version>
   </PropertyGroup>
   <PropertyGroup Label="Configuration">
     <Import_RootNamespace>BepInEx.Shared</Import_RootNamespace>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)BuildInfoAttribute.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)VersionInfo.cs" />
+  </ItemGroup>
+  
+  <ItemGroup Condition="'$(BuildInfo)' != ''">
+    <AssemblyAttribute Include="BepInEx.Shared.BuildInfoAttribute">
+        <_Parameter1>$(BuildInfo)</_Parameter1>
+    </AssemblyAttribute>
   </ItemGroup>
 </Project>

+ 1 - 0
BepInEx.Shared/BuildInfoAttribute.cs

@@ -6,6 +6,7 @@ namespace BepInEx.Shared
 	/// This class is appended to AssemblyInfo.cs when BepInEx is built via a CI pipeline.
 	/// It is mainly intended to signify that the current build is not a release build and is special, like for instance a bleeding edge build.
 	/// </summary>
+	[AttributeUsage(AttributeTargets.Assembly)]
 	public class BuildInfoAttribute : Attribute
 	{
 		public string Info { get; }

+ 0 - 7
BepInEx.Shared/VersionInfo.cs

@@ -1,7 +0,0 @@
-namespace BepInEx.Shared
-{
-	internal static class VersionInfo
-	{
-		public const string VERSION = "6.0.0.0";
-	}
-}

+ 0 - 10
BepInEx.Unity/BepInEx.Unity.csproj

@@ -6,10 +6,6 @@
     <OutputPath>..\bin\Unity\</OutputPath>
     <LangVersion>8</LangVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
-    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
-    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
-    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>full</DebugType>
@@ -32,11 +28,5 @@
   <ItemGroup>
     <PackageReference Include="HarmonyX" Version="2.1.1" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
   <Import Project="..\BepInEx.Shared\BepInEx.Shared.projitems" Label="Shared" />
 </Project>

+ 1 - 7
BepInExTests/BepInExTests.csproj

@@ -10,7 +10,7 @@
     <UpgradeBackupLocation />
     <AssemblyTitle>BepInExTests</AssemblyTitle>
     <Product>BepInExTests</Product>
-    <Copyright>Copyright ©  2019</Copyright>
+    <Copyright>Copyright © 2020 BepInEx Team</Copyright>
     <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
@@ -39,10 +39,4 @@
     <ProjectReference Include="..\BepInEx.IL2CPP\BepInEx.IL2CPP.csproj" />
     <ProjectReference Include="..\BepInEx.Unity\BepInEx.Unity.csproj" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Remove="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
 </Project>

+ 21 - 29
build.cake

@@ -1,8 +1,8 @@
-#addin nuget:?package=Cake.FileHelpers&version=3.2.1
-#addin nuget:?package=SharpZipLib&version=1.2.0
+#addin nuget:?package=Cake.FileHelpers&version=3.3.0
+#addin nuget:?package=SharpZipLib&version=1.3.0
 #addin nuget:?package=Cake.Compression&version=0.2.4
-#addin nuget:?package=Cake.Json&version=4.0.0
-#addin nuget:?package=Newtonsoft.Json&version=11.0.2
+#addin nuget:?package=Cake.Json&version=5.2.0
+#addin nuget:?package=Newtonsoft.Json&version=12.0.3
 
 var target = Argument("target", "Build");
 var isBleedingEdge = Argument("bleeding_edge", false);
@@ -53,26 +53,29 @@ Task("Build")
 {
     var bepinExProperties = Directory("./BepInEx.Shared");
 
-    if(isBleedingEdge)
-    {
-        CopyFile(bepinExProperties + File("VersionInfo.cs"), bepinExProperties + File("VersionInfo.cs.bak"));
-        CopyFile(bepinExProperties + File("AssemblyInfo.cs"), bepinExProperties + File("AssemblyInfo.cs.bak"));
-        ReplaceRegexInFiles(bepinExProperties + File("VersionInfo.cs"), "([0-9]+\\.[0-9]+\\.[0-9]+\\.)[0-9]+", "${1}" + buildId);
+    buildVersion = FindRegexMatchGroupInFile(bepinExProperties + File("BepInEx.Shared.projitems"), @"\<Version\>([0-9]+\.[0-9]+\.[0-9]+)\<\/Version\>", 1, System.Text.RegularExpressions.RegexOptions.None).Value;
 
-        FileAppendText(bepinExProperties + File("AssemblyInfo.cs"), 
-            TransformText("\n[assembly: BuildInfo(\"BLEEDING EDGE Build #<%buildNumber%> from <%shortCommit%> at <%branchName%>\")]\n")
+    var buildSettings = new MSBuildSettings {
+        Configuration = "Release",
+        Restore = true
+    };
+
+    if (isBleedingEdge) 
+    {
+        buildSettings.Properties["BuildInfo"] = new[] {
+            TransformText("BLEEDING EDGE Build #<%buildNumber%> from <%shortCommit%> at <%branchName%>")
                 .WithToken("buildNumber", buildId)
                 .WithToken("shortCommit", currentCommit)
                 .WithToken("branchName", currentBranch)
-                .ToString());
-    }
+                .ToString()
+        };
 
-    buildVersion = FindRegexMatchInFile(bepinExProperties + File("VersionInfo.cs"), "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", System.Text.RegularExpressions.RegexOptions.None);
+        buildSettings.Properties["AssemblyVersion"] = new[] { buildVersion + "." + buildId };
 
-    var buildSettings = new MSBuildSettings {
-        Configuration = "Release",
-        Restore = true
-    };
+        buildVersion += "-be." + buildId;
+
+        buildSettings.Properties["Version"] = new[] { buildVersion };
+    }
 
     //buildSettings.Properties["TargetFrameworks"] = new []{ "net35" };
     MSBuild("./BepInEx.Unity/BepInEx.Unity.csproj", buildSettings);
@@ -82,17 +85,6 @@ Task("Build")
     
     //buildSettings.Properties["TargetFrameworks"] = new []{ "net472" };
     MSBuild("./BepInEx.IL2CPP/BepInEx.IL2CPP.csproj", buildSettings);
-})
-.Finally(() => 
-{
-    var bepinExProperties = Directory("./BepInEx.Shared");
-    if(isBleedingEdge)
-    {
-        DeleteFile(bepinExProperties + File("AssemblyInfo.cs"));
-        DeleteFile(bepinExProperties + File("VersionInfo.cs"));
-        MoveFile(bepinExProperties + File("AssemblyInfo.cs.bak"), bepinExProperties + File("AssemblyInfo.cs"));
-        MoveFile(bepinExProperties + File("VersionInfo.cs.bak"), bepinExProperties + File("VersionInfo.cs"));
-    }
 });
 
 const string DOORSTOP_VER_WIN = "3.1.0.0";