summarylogtreecommitdiffstats
path: root/build.sh
diff options
context:
space:
mode:
authorKyle Sferrazza2017-09-15 16:15:34 -0400
committerKyle Sferrazza2017-09-15 16:15:34 -0400
commit31801cb7da480fb31ce6d7f6b12cf4e2e65dccfc (patch)
tree5338266373a3a2767a039d6fbd0f4382c5a50b26 /build.sh
parentfa262171a67a0c9345454bd8e7813883b93d638b (diff)
downloadaur-31801cb7da480fb31ce6d7f6b12cf4e2e65dccfc.tar.gz
beta 7
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 000000000000..33c4d7452cc7
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+set -e
+
+if hash powershell 2>/dev/null; then
+ echo 'Continuing with `powershell -noprofile -c Start-PSBuild`'
+ powershell -noprofile -c "Import-Module ./build.psm1; Start-PSBuild"
+else
+ echo 'Continuing with full manual build'
+
+ ## Restore
+ dotnet restore src/powershell-unix
+ dotnet restore src/ResGen
+ dotnet restore src/TypeCatalogGen
+
+ ## Setup the build target to gather dependency information
+ targetFile="$(pwd)/src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
+ cat > $targetFile <<-"EOF"
+<Project>
+ <Target Name="_GetDependencies"
+ DependsOnTargets="ResolveAssemblyReferencesDesignTime">
+ <ItemGroup>
+ <_RefAssemblyPath Include="%(_ReferencesFromRAR.ResolvedPath)%3B" Condition=" '%(_ReferencesFromRAR.Type)' == 'assembly' And '%(_ReferencesFromRAR.PackageName)' != 'Microsoft.Management.Infrastructure' " />
+ </ItemGroup>
+ <WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
+ </Target>
+</Project>
+EOF
+ dotnet msbuild src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$(pwd)/src/TypeCatalogGen/powershell.inc" /nologo
+
+ ## Generate 'powershell.version'
+ git --git-dir="$(pwd)/.git" describe --dirty --abbrev=60 > "$(pwd)/powershell.version"
+
+ ## create the telemetry flag file
+ touch "$(pwd)/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY"
+
+ ## Generate resource binding C# files
+ pushd src/ResGen
+ dotnet run
+ popd
+
+ ## Generate 'CorePsTypeCatalog.cs'
+ pushd src/TypeCatalogGen
+ dotnet run ../Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CorePsTypeCatalog.cs powershell.inc
+ popd
+
+ ## Build native component
+ pushd src/libpsl-native
+ cmake -DCMAKE_BUILD_TYPE=Debug .
+ make -j
+ make test
+ popd
+
+ ## Build powershell core
+ rawRid="$(dotnet --info | grep RID)"
+ rid=${rawRid##* } # retain the part after the last space
+ dotnet publish --configuration Linux src/powershell-unix/ --output bin --runtime $rid
+
+ echo 'You can run powershell from bin/, but some modules that are normally added by the Restore-PSModule step will not be available.'
+fi