diff --git a/AutoTx/ATXProject.csproj b/AutoTx/ATXProject.csproj index 5af4a78b04a2e94d08992eeadbb71ef252a9b135..65e71b0874ea64f5b6c81d7024fb45702597e911 100644 --- a/AutoTx/ATXProject.csproj +++ b/AutoTx/ATXProject.csproj @@ -152,7 +152,7 @@ </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PreBuildEvent>PowerShell -Command "$BCommit = '$(ProjectDir)\Resources\BuildCommit.txt' ; $BDate = '$(ProjectDir)\Resources\BuildDate.txt' ; if (-Not (Test-Path $BCommit)) { Write-Output 'UNKNOWN' > $BCommit } ; Get-Date -Format 'yyyy-MM-dd HH:mm:ss' > $BDate ; Get-Content $BDate"</PreBuildEvent> + <PreBuildEvent>PowerShell -NoProfile -ExecutionPolicy RemoteSigned $(SolutionDir)\Scripts\Prepare-Build.ps1 $(ProjectDir)</PreBuildEvent> </PropertyGroup> <PropertyGroup> <PostBuildEvent>PowerShell -Command "Write-Host $(ConfigurationName)" > $(ProjectDir)\Resources\BuildConfiguration.txt diff --git a/Scripts/Prepare-Build.ps1 b/Scripts/Prepare-Build.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..ca337d20ebf50ad528f84e93afdba35c097b5024 --- /dev/null +++ b/Scripts/Prepare-Build.ps1 @@ -0,0 +1,36 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True)][string] $ProjectDir +) + +$oldpwd = pwd +cd $ProjectDir -ErrorAction Stop + +try { + $CommitName = git describe --tags + $GitStatus = git status --porcelain +} +catch { + $CommitName = "commit unknown" + $GitStatus = "status unknown" +} + + +if ($GitStatus.Length -gt 0) { + Write-Output "NOTE: repository has uncommitted changes!" + $CommitName = "$($CommitName)-unclean" +} + +$Date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' + + +$BCommit = "$($ProjectDir)\Resources\BuildCommit.txt" +$BuildDate = "$($ProjectDir)\Resources\BuildDate.txt" + +Write-Output $CommitName > $BCommit +Write-Output $Date > $BuildDate + +Write-Output $Date +Write-Output $CommitName + +cd $oldpwd \ No newline at end of file