Skip to content

Commit

Permalink
SKA-289: Fixed build script
Browse files Browse the repository at this point in the history
* The build project now recusively copies the entire ThirdParty folder and its contents
* The publish folder is being zipped again
* General code formatting for improved readabiltiy
  • Loading branch information
DominikHerr committed Sep 26, 2023
1 parent c88a6a3 commit 7a443eb
Showing 1 changed file with 64 additions and 42 deletions.
106 changes: 64 additions & 42 deletions FmuImporter/BuildAll/Build.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- SPDX-License-Identifier: MIT -->
<!-- Copyright (c) Vector Informatik GmbH. All rights reserved. -->

<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="BuildOsDependent;BuildXPlatform">
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="BuildOsDependent;BuildXPlatform;PrepareReleasePackage">
<Import Project="../common.props" Condition="$(CommonImported) == ''" />

<!--Currently disabled-->
Expand All @@ -20,34 +20,46 @@
</PropertyGroup>

<!-- win-x64 -->
<Exec Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_win-x64 -p:RuntimeIdentifier=win-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_win-x64 -p:RuntimeIdentifier=win-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />

<!-- linux-x64 -->
<Exec Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_linux-x64 -p:RuntimeIdentifier=linux-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_linux-x64 -p:RuntimeIdentifier=linux-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />

<!-- osx-x64 -->
<Exec Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_osx-x64 -p:RuntimeIdentifier=osx-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(StandaloneBuild) -p:RuntimeIdentifier=osx-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(StandaloneBuild) -p:PublishProfile=publishStandalone_osx-x64 -p:RuntimeIdentifier=osx-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
</Target>

<Target Name="BuildXPlatform" BeforeTargets="Build">
Expand All @@ -64,27 +76,33 @@
</PropertyGroup>

<!-- cross-platform x64 -->
<Exec Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)SilKitBridge/SilKitBridge.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmiBridge/FmiBridge.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(CrossPlatformBuild) -p:RuntimeIdentifier=linux-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="chmod a+x $(MSBuildProjectDirectory)/../_build/crossplatform-x64-Release/FmuImporter"
Condition="$([MSBuild]::IsOSPlatform('Linux'))"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:PublishProfile=publishCrossPlatform-x64 -p:RuntimeIdentifier=linux-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:PublishProfile=publishCrossPlatform-x64 -p:RuntimeIdentifier=linux-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Move SourceFiles="$(MSBuildProjectDirectory)/../_build/crossplatform-x64-Release/FmuImporter"
OverwriteReadOnlyFiles="true"
DestinationFiles="$(MSBuildProjectDirectory)/../_build/crossplatform-x64-Release/FmuImporter.tmp" />
<Move SourceFiles="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/FmuImporter"
OverwriteReadOnlyFiles="true"
DestinationFiles="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/FmuImporter.tmp" />
<Exec Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(CrossPlatformBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:PublishProfile=publishCrossPlatform-x64 -p:RuntimeIdentifier=win-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet build $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) -p:BuildProjectReferences=false $(CrossPlatformBuild) -p:RuntimeIdentifier=win-x64"
EnvironmentVariables="$(EnvVar)" />
<Exec
Command="dotnet publish $(BuildPath)FmuImporter/FmuImporter.csproj $(DefaultProperties) $(CrossPlatformBuild) -p:PublishProfile=publishCrossPlatform-x64 -p:RuntimeIdentifier=win-x64 --no-build"
EnvironmentVariables="$(EnvVar)" />
<Move SourceFiles="$(MSBuildProjectDirectory)/../_build/crossplatform-x64-Release/FmuImporter.tmp"
OverwriteReadOnlyFiles="true"
DestinationFiles="$(MSBuildProjectDirectory)/../_build/crossplatform-x64-Release/FmuImporter" />
Expand All @@ -99,8 +117,11 @@
DestinationFolder="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/" />
</Target>

<Target Name="Prepare cross-platform release package"
AfterTargets="BuildAll">
<Target Name="PrepareReleasePackage"
AfterTargets="BuildXPlatform">
<ItemGroup>
<ThirdPartyFiles Include="$(MSBuildProjectDirectory)/../../ThirdParty/**/*.*" />
</ItemGroup>
<PropertyGroup>
<PublishPath>$(MSBuildProjectDirectory)/../_publish/</PublishPath>
<CrossPlatformTargetFolderName>SilKitFmuImporter-$(Version)-xPlatform-x64</CrossPlatformTargetFolderName>
Expand All @@ -113,10 +134,11 @@
SourceFiles="$(MSBuildProjectDirectory)/../../LICENSE"
DestinationFolder="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/" />
<Copy
SourceFiles="$(MSBuildProjectDirectory)/../../ThirdParty/LICENSES.rst"
DestinationFolder="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/ThirdParty/" />
SourceFiles="@(ThirdPartyFiles)"
DestinationFolder="$(PublishPath)crossplatform-x64/$(CrossPlatformTargetFolderName)/ThirdParty/%(RecursiveDir)" />

<Message Text="Zipping cross-platform build to '$(PublishPath)$(CrossPlatformTargetFolderName).zip'..." Importance="High" />
<Message Text="Zipping cross-platform build to '$(PublishPath)$(CrossPlatformTargetFolderName).zip'..."
Importance="High" />
<ZipDirectory SourceDirectory="$(PublishPath)crossplatform-x64/"
DestinationFile="$(PublishPath)/$(CrossPlatformTargetFolderName).zip"
Overwrite="True" />
Expand Down

0 comments on commit 7a443eb

Please sign in to comment.