Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Content/Console/.fantomasignore

This file was deleted.

3 changes: 1 addition & 2 deletions Content/Console/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<PackageVersion Include="FAKE.Core.Environment" Version="$(FakeVersion)" />
<PackageVersion Include="Fake.DotNet.Cli" Version="$(FakeVersion)" />
<PackageVersion Include="FAKE.Core.Process" Version="$(FakeVersion)" />
<PackageVersion Include="Fake.DotNet.AssemblyInfoFile" Version="$(FakeVersion)" />
<PackageVersion Include="Fake.Tools.Git" Version="$(FakeVersion)" />
<PackageVersion Include="Fake.Api.GitHub" Version="$(FakeVersion)" />
<PackageVersion Include="Fake.BuildServer.GitHubActions" Version="$(FakeVersion)" />
Expand All @@ -47,4 +46,4 @@
<PackageVersion Include="G-Research.FSharp.Analyzers" Version="0.19.0" />

</ItemGroup>
</Project>
</Project>
1 change: 0 additions & 1 deletion Content/Console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ $ ./build.sh <optional buildtarget>// on unix
- `GenerateCoverageReport` - Code coverage is run during `DotnetTest` and this generates a report via [ReportGenerator](https://github.com/danielpalme/ReportGenerator).
- `WatchApp` - Runs [dotnet watch](https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.0) on the application. Useful for rapid feedback loops.
- `WatchTests` - Runs [dotnet watch](https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.0) with the test projects. Useful for rapid feedback loops.
- `GenerateAssemblyInfo` - Generates [AssemblyInfo](https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.applicationservices.assemblyinfo?view=netframework-4.8) for libraries.
- `CreatePackages` - Runs the packaging task from [dotnet-packaging](https://github.com/qmfrederik/dotnet-packaging). This creates applications for `win-x64`, `osx-x64` and `linux-x64` - [Runtime Identifiers](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog).
- Bundles the `win-x64` application in a .zip file.
- Bundles the `osx-x64` application in a .tar.gz file.
Expand Down
103 changes: 24 additions & 79 deletions Content/Console/build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,28 @@ let failOnBadExitAndPrint (p: ProcessResult) =

failwithf "failed with exitcode %d" p.ExitCode

let assemblyInfoMsBuildArgs () =
let releaseChannel =
match latestEntry.SemVer.PreRelease with
| Some pr -> pr.Name
| _ -> "release"

let gitHash =
try
Git.Information.getCurrentSHA1 (null)
with _ ->
""

[
sprintf "/p:Version=%s" latestEntry.AssemblyVersion
sprintf "/p:AssemblyVersion=%s" latestEntry.AssemblyVersion
sprintf "/p:FileVersion=%s" latestEntry.AssemblyVersion
sprintf "/p:InformationalVersion=%s" latestEntry.AssemblyVersion
sprintf "/p:AssemblyMetadataReleaseDate=%s" (latestEntry.Date.Value.ToString("o"))
sprintf "/p:AssemblyMetadataReleaseChannel=%s" releaseChannel
sprintf "/p:AssemblyMetadataGitHash=%s" gitHash
]

let rec retryIfInCI times fn =
if isCI.Value then
if times > 1 then
Expand Down Expand Up @@ -423,63 +445,6 @@ let watchTests _ =

cancelEvent.Cancel <- true

let generateAssemblyInfo _ =

let (|Fsproj|Csproj|Vbproj|) (projFileName: string) =
match projFileName with
| f when f.EndsWith("fsproj") -> Fsproj
| f when f.EndsWith("csproj") -> Csproj
| f when f.EndsWith("vbproj") -> Vbproj
| _ ->
failwith (sprintf "Project file %s not supported. Unknown project type." projFileName)

let releaseChannel =
match latestEntry.SemVer.PreRelease with
| Some pr -> pr.Name
| _ -> "release"

let getAssemblyInfoAttributes projectName = [
AssemblyInfo.Title(projectName)
AssemblyInfo.Product productName
AssemblyInfo.Version latestEntry.AssemblyVersion
AssemblyInfo.Metadata("ReleaseDate", latestEntry.Date.Value.ToString("o"))
AssemblyInfo.FileVersion latestEntry.AssemblyVersion
AssemblyInfo.InformationalVersion latestEntry.AssemblyVersion
AssemblyInfo.Metadata("ReleaseChannel", releaseChannel)
AssemblyInfo.Metadata("GitHash", Git.Information.getCurrentSHA1 (null))
]

let getProjectDetails (projectPath: string) =
let projectName = IO.Path.GetFileNameWithoutExtension(projectPath)

(projectPath,
projectName,
IO.Path.GetDirectoryName(projectPath),
(getAssemblyInfoAttributes projectName))

!!srcGlob
|> Seq.map getProjectDetails
|> Seq.iter (fun (projFileName, _, folderName, attributes) ->
match projFileName with
| Fsproj ->
AssemblyInfoFile.createFSharp
(folderName
@@ "AssemblyInfo.fs")
attributes
| Csproj ->
AssemblyInfoFile.createCSharp
((folderName
@@ "Properties")
@@ "AssemblyInfo.cs")
attributes
| Vbproj ->
AssemblyInfoFile.createVisualBasic
((folderName
@@ "My Project")
@@ "AssemblyInfo.vb")
attributes
)

let createPackages _ =
runtimes
|> Seq.iter (fun (runtime, packageType) ->
Expand All @@ -491,6 +456,7 @@ let createPackages _ =
sprintf "/p:RuntimeIdentifier=%s" runtime
sprintf "/p:Configuration=%s" "Release"
sprintf "/p:PackageVersion=%s" latestEntry.NuGetVersion
yield! assemblyInfoMsBuildArgs ()
sprintf
"/p:PackagePath=\"%s\""
(distDir
Expand All @@ -510,12 +476,6 @@ let gitRelease _ =
Git.Staging.stageFile "" "CHANGELOG.md"
|> ignore

!!"src/**/AssemblyInfo.fs"
|> Seq.iter (
Git.Staging.stageFile ""
>> ignore
)

Git.Commit.exec
""
(sprintf "Bump version to %s\n\n%s" latestEntry.NuGetVersion releaseNotesGitCommitFormat)
Expand Down Expand Up @@ -606,7 +566,6 @@ let initTargets () =
Target.create "GenerateCoverageReport" generateCoverageReport
Target.create "WatchApp" watchApp
Target.create "WatchTests" watchTests
Target.create "AssemblyInfo" generateAssemblyInfo
Target.create "CreatePackages" createPackages
Target.create "GitRelease" gitRelease
Target.create "GitHubRelease" githubRelease
Expand All @@ -626,25 +585,11 @@ let initTargets () =
"Clean"
==>! "CreatePackages"

// Only call AssemblyInfo if there is a release target in the call chain
// Ensure AssemblyInfo is called after DotnetRestore and before DotnetBuild
"DotnetRestore"
?=>! "AssemblyInfo"

"AssemblyInfo"
?=>! "DotnetBuild"

"AssemblyInfo"
==>! "GitRelease"

// Only call UpdateChangelog if there is a release target in the call chain
// Ensure UpdateChangelog is called after DotnetRestore and before AssemblyInfo
// Ensure UpdateChangelog is called after DotnetRestore
"DotnetRestore"
?=>! "UpdateChangelog"

"UpdateChangelog"
?=>! "AssemblyInfo"

"UpdateChangelog"
==>! "GitRelease"

Expand Down
1 change: 0 additions & 1 deletion Content/Console/build/build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<PackageReference Include="FAKE.Core.Environment" />
<PackageReference Include="Fake.DotNet.Cli" />
<PackageReference Include="FAKE.Core.Process" />
<PackageReference Include="Fake.DotNet.AssemblyInfoFile" />
<PackageReference Include="Fake.Tools.Git" />
<PackageReference Include="Fake.Api.GitHub" />
<PackageReference Include="Fake.BuildServer.GitHubActions" />
Expand Down
2 changes: 2 additions & 0 deletions Content/Console/src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Product>$(MSBuildProjectName)</Product>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

Expand Down
19 changes: 17 additions & 2 deletions Content/Console/src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
<Project>
<PropertyGroup>
<PropertyGroup>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<FSharpAnalyzersOtherFlags>--analyzers-path "$(PkgG-Research_FSharp_Analyzers)/analyzers/dotnet/fs"</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --analyzers-path "$(PkgIonide_Analyzers)/analyzers/dotnet/fs"</FSharpAnalyzersOtherFlags>
</PropertyGroup>
</Project>

<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(AssemblyMetadataReleaseDate)' != ''">
<_Parameter1>ReleaseDate</_Parameter1>
<_Parameter2>$(AssemblyMetadataReleaseDate)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(AssemblyMetadataReleaseChannel)' != ''">
<_Parameter1>ReleaseChannel</_Parameter1>
<_Parameter2>$(AssemblyMetadataReleaseChannel)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(AssemblyMetadataGitHash)' != ''">
<_Parameter1>GitHash</_Parameter1>
<_Parameter2>$(AssemblyMetadataGitHash)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Project>
23 changes: 0 additions & 23 deletions Content/Console/src/MyLib.1/AssemblyInfo.fs

This file was deleted.

1 change: 0 additions & 1 deletion Content/Console/src/MyLib.1/MyLib.1.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PackageReference Include="Packaging.Targets" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<None Include="App.config" />
<Compile Include="Main.fs" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Content/Library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ src/MyLib.1/bin/
- `GenerateCoverageReport` - Code coverage is run during `DotnetTest` and this generates a report via [ReportGenerator](https://github.com/danielpalme/ReportGenerator).
- `ShowCoverageReport` - Shows the report generated in `GenerateCoverageReport`.
- `WatchTests` - Runs [dotnet watch](https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.0) with the test projects. Useful for rapid feedback loops.
- `GenerateAssemblyInfo` - Generates [AssemblyInfo](https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.applicationservices.assemblyinfo?view=netframework-4.8) for libraries.
- `DotnetPack` - Runs [dotnet pack](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack). This includes running [Source Link](https://github.com/dotnet/sourcelink).
- `SourceLinkTest` - Runs a Source Link test tool to verify Source Links were properly generated.
- `PublishToNuGet` - Publishes the NuGet packages generated in `DotnetPack` to NuGet via [nuget push](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push). Runs only from `Github Actions`.
Expand Down
Loading
Loading