Skip to content

Commit

Permalink
Fixes runtime identifer code generation
Browse files Browse the repository at this point in the history
This didn't work at all - I don't know why I ever thought it was working 🤦‍♂️

Work done for #196
  • Loading branch information
atruskie committed Mar 29, 2020
1 parent d32268d commit ebfe8e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions src/AP.VersionBuild.targets
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Register our task that as something to run before standard build target -->
<Target Name="APVersionBeforeBuild" BeforeTargets="PrepareForBuild">
<Exec Command="pwsh –NonInteractive -noprofile $(ProjectDir)../git_version.ps1 -configuration $(Configuration) -self_contained $(SelfContained) -runtime_identifier $(RuntimeIdentifier)"
ConsoleToMSBuild="True"
EchoOff="false"
StandardOutputImportance="low" >
<Output TaskParameter="ConsoleOutput" ItemName="VersionMetadata" />
<!-- <Message Text="[APVersionBeforeBuild] Debug: $(RuntimeIdentifier)" Importance="High" /> -->
<Exec Command="pwsh –NonInteractive -noprofile $(ProjectDir)../git_version.ps1 -configuration $(Configuration) -self_contained $(SelfContained) -runtime_identifier '$(RuntimeIdentifier)'" ConsoleToMSBuild="True" EchoOff="false" StandardOutputImportance="low">
<Output TaskParameter="ConsoleOutput" ItemName="VersionMetadata" />
</Exec>
<Message Text="[APVersionBeforeBuild] %(VersionMetadata.Indentity)" Importance="High" />
<!-- <Message Text="[APVersionBeforeBuild] %(VersionMetadata.Identity)" Importance="High" /> -->
<!-- batch through returned metadata, then use ✨MAGIC✨ to convert subexpression to string, then split on key/value -->
<!-- and finally create each property -->
<CreateProperty Value="$([System.String]::Copy(`%(VersionMetadata.Identity)`).Split('=')[1].Trim())">
Expand All @@ -23,8 +22,7 @@
<Message Text="[APVersionBeforeBuild] BuildDate: $(BuildDate)" Importance="High" />
<Message Text="[APVersionBeforeBuild] SelfContained: $(MsBuildSelfContained), Build RuntimeIdentifier:$(MsBuildRuntimeIdentifer)" Importance="High" />
<Message Text="[APVersionBeforeBuild] git_version.ps1 stdout: %(VersionMetadata.Identity)" Importance="High" Condition="$(GeneratedMetadata) == ''"/>

<Error Text="AP Version metadata generation failed. Check you have PowerShell 6+ &amp; Git installed and available on the system PATH."
Condition="$(GeneratedMetadata) == ''"/>
<Error Text="AP Version script failed to set MsBuildRuntimeIdentifer. This value is needed for correct function in compiled code" Condition="$(MsBuildRuntimeIdentifer) == '' And $(SelfContained)" />
<Error Text="AP Version metadata generation failed. Check you have PowerShell 6+ &amp; Git installed and available on the system PATH." Condition="$(GeneratedMetadata) == ''"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/AssemblyMetadata.cs.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace AnalysisPrograms
public const string CiBuild = "${build_number}";

public const bool CompiledAsSelfContained = ${self_contained};
public const string CompiledRuntimeIdentifer = "${runtime_identifer}";
public const string CompiledRuntimeIdentifer = "${runtime_identifier}";
public const string CompiledConfiguration = "${configuration}";

public static readonly Version Version = new Version("${version}");
Expand Down
4 changes: 2 additions & 2 deletions src/git_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ param(

[string]$configuration,
[string]$self_contained,
[string]$runtime_indentifier
[string]$runtime_identifier
)

Push-Location
Expand Down Expand Up @@ -73,7 +73,7 @@ InformationalVersion=$informational_version
GeneratedMetadata=$metadata_file
CacheWarning=$cache_warning
MsBuildSelfContained=$self_contained
MsBuildRuntimeIdentifer=$runtime_identifer
MsBuildRuntimeIdentifer=$runtime_identifier
MsBuildConfiguration=$configuration
"@

Expand Down

0 comments on commit ebfe8e8

Please sign in to comment.