2015-11-13 22:54:44 +01:00
|
|
|
#!/usr/bin/env bash
|
2016-12-28 22:59:51 +01:00
|
|
|
set -e
|
2015-11-13 22:54:44 +01:00
|
|
|
|
2016-04-07 23:18:12 +02:00
|
|
|
if hash powershell 2>/dev/null; then
|
2016-05-18 23:24:08 +02:00
|
|
|
echo 'Continuing with `powershell -noprofile -c Start-PSBuild`'
|
|
|
|
powershell -noprofile -c "Import-Module ./build.psm1; Start-PSBuild"
|
2016-04-07 23:18:12 +02:00
|
|
|
else
|
2016-12-28 22:59:51 +01:00
|
|
|
echo 'Continuing with full manual build'
|
|
|
|
|
2017-03-23 21:04:52 +01:00
|
|
|
## 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="ResolvePackageDependenciesDesignTime">
|
|
|
|
<ItemGroup>
|
|
|
|
<_DependentAssemblyPath Include="%(_DependenciesDesignTime.Path)%3B" Condition=" '%(_DependenciesDesignTime.Type)' == 'Assembly' And '%(_DependenciesDesignTime.Name)' != 'Microsoft.Management.Infrastructure.Native.dll' And '%(_DependenciesDesignTime.Name)' != 'Microsoft.Management.Infrastructure.dll' " />
|
|
|
|
</ItemGroup>
|
|
|
|
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_DependentAssemblyPath)" 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"
|
|
|
|
|
|
|
|
## Generate resource binding C# files
|
|
|
|
pushd src/ResGen
|
2016-12-28 22:59:51 +01:00
|
|
|
dotnet run
|
|
|
|
popd
|
|
|
|
|
2017-03-23 21:04:52 +01:00
|
|
|
## Generate 'CorePsTypeCatalog.cs'
|
2016-12-28 22:59:51 +01:00
|
|
|
pushd src/TypeCatalogGen
|
|
|
|
dotnet run ../Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CorePsTypeCatalog.cs powershell.inc
|
|
|
|
popd
|
|
|
|
|
2017-03-23 21:04:52 +01:00
|
|
|
## Build native component
|
2016-12-28 22:59:51 +01:00
|
|
|
pushd src/libpsl-native
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Debug .
|
|
|
|
make -j
|
|
|
|
make test
|
|
|
|
popd
|
|
|
|
|
2017-03-23 21:04:52 +01:00
|
|
|
## 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
|
2016-12-28 22:59:51 +01:00
|
|
|
|
|
|
|
echo 'You can run powershell from bin/, but some modules that are normally added by the Restore-PSModule step will not be available.'
|
2016-04-07 23:18:12 +02:00
|
|
|
fi
|