8000 Move Start-TypeGen logic from Build.psm1 to SDK csproj file (Target N… · PowerShell/PowerShell@7ca0125 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ca0125

Browse files
committed
Move Start-TypeGen logic from Build.psm1 to SDK csproj file (Target Name="TypeCatalogGen")
1 parent 381134b commit 7ca0125

File tree

2 files changed

+54
-25
lines changed

2 files changed

+54
-25
lines changed

build.psm1

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ Fix steps:
535535

536536
# publish netcoreapp2.0 reference assemblies
537537
try {
538-
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
539-
$refAssemblies = Get-Content -Path $incFileName | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
538+
Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK/gen"
539+
$refAssemblies = Get-Content -Path "RefAssemblyList.inc" | Where-Object { $_ -like "*microsoft.netcore.app*" } | ForEach-Object { $_.TrimEnd(';') }
540540
$refDestFolder = Join-Path -Path $publishPath -ChildPath "ref"
541541

542542
if (Test-Path $refDestFolder -PathType Container) {
@@ -1715,33 +1715,12 @@ function Start-TypeGen
17151715
# Add .NET CLI tools to PATH
17161716
Find-Dotnet
17171717

1718-
$GetDependenciesTargetPath = "$PSScriptRoot/src/Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets"
1719-
$GetDependenciesTargetValue = @'
1720-
<Project>
1721-
<Target Name="_GetDependencies"
1722-
DependsOnTargets="ResolveAssemblyReferencesDesignTime">
1723-
<ItemGroup>
1724-
<_RefAssemblyPath Include="%(_ReferencesFromRAR.ResolvedPath)%3B" Condition=" '%(_ReferencesFromRAR.Type)' == 'assembly' And '%(_ReferencesFromRAR.PackageName)' != 'Microsoft.Management.Infrastructure' " />
1725-
</ItemGroup>
1726-
<WriteLinesToFile File="$(_DependencyFile)" Lines="@(_RefAssemblyPath)" Overwrite="true" />
1727-
</Target>
1728-
</Project>
1729-
'@
1730-
Set-Content -Path $GetDependenciesTargetPath -Value $GetDependenciesTargetValue -Force -Encoding Ascii
1731-
17321718
Push-Location "$PSScriptRoot/src/Microsoft.PowerShell.SDK"
17331719
try {
1734-
$ps_inc_file = "$PSScriptRoot/src/TypeCatalogGen/$IncFileName"
1735-
dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:_GetDependencies "/property:DesignTimeBuild=true;_DependencyFile=$ps_inc_file" /nologo
1736-
} finally {
1737-
Pop-Location
1738-
}
1739-
1740-
Push-Location "$PSScriptRoot/src/TypeCatalogGen"
1741-
try {
1742-
dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs $IncFileName
1720+
dotnet msbuild .\Microsoft.PowerShell.SDK.csproj /t:"Clean;TypeCatalogGen" "/property:DesignTimeBuild=true"
17431721
} finally {
17441722
Pop-Location
1723+
log "Finish Start-TypeGen"
17451724
}
17461725
}
17471726

src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,54 @@
2929
<PackageReference Include="Microsoft.NETCore.Windows.ApiSets" Version="1.0.1" />
3030
</ItemGroup>
3131

32+
<!-- TypeCatalogGen properties -->
33+
<PropertyGroup>
34+
<RefAssemblyRelPath>gen</RefAssemblyRelPath>
35+
<RefAssemblyFileName>RefAssemblyList.inc</RefAssemblyFileName>
36+
<RefAssemblyDirPath>$(MSBuildProjectDirectory)\$(RefAssemblyRelPath)</RefAssemblyDirPath>
37+
<RefAssemblyFilePath>$(RefAssemblyDirPath)\$(RefAssemblyFileName)</RefAssemblyFilePath>
38+
39+
<CorePsTypeCatalogFilePath>$(MSBuildProjectDirectory)\..\Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/CorePsTypeCatalog.cs</CorePsTypeCatalogFilePath>
40+
<TypeCatalogProjectFilePath>$(MSBuildProjectDirectory)\..\TypeCatalogGen\TypeCatalogGen.csproj</TypeCatalogProjectFilePath>
41+
</PropertyGroup>
42+
43+
<!-- Create file with Assembly Reference list -->
44+
<Target Name="ResolveAssemblyReferencesDesignTimeSDK"
45+
DependsOnTargets="ResolveAssemblyReferencesDesignTime"
46+
Condition=" '$(DesignTimeBuild)' == 'true' ">
47+
48+
<MakeDir Directories="$(RefAssemblyRelPath)" Condition=" !Exists('$(RefAssemblyRelPath)') "/>
49+
50+
<ItemGroup>
51+
<_RefAssemblyPath Include="%(_ReferencesFromRAR.ResolvedPath)%3B" Condition=" '%(_ReferencesFromRAR.Type)' == 'assembly' And '%(_ReferencesFromRAR.PackageName)' != 'Microsoft.Management.Infrastructure' " />
52+
</ItemGroup>
53+
54+
<ReadLinesFromFile
55+
File="$(RefAssemblyFilePath)" >
56+
<Output
57+
TaskParameter="Lines"
58+
ItemName="ItemsFromFile"/>
59+
</ReadLinesFromFile>
60+
61+
<WriteLinesToFile
62+
Condition=" @(ItemsFromFile) != @(_RefAssemblyPath) "< A65D /span>
63+
File="$(RefAssemblyFilePath)"
64+
Lines="@(_RefAssemblyPath)" Overwrite="true" />
65+
</Target>
66+
67+
<!-- Used in standard Clean target -->
68+
<ItemGroup>
69+
<Clean Include="$(RefAssemblyDirPath)\**"/>
70+
</ItemGroup>
71+
72+
<Target Name="TypeCatalogGen"
73+
DependsOnTargets="ResolveAssemblyReferencesDesignTimeSDK"
74+
Condition=" '$(DesignTimeBuild)' == 'true' "
75+
Inputs="$(RefAssemblyFilePath)"
76+
Outputs="$(CorePsTypeCatalogFilePath)">
77+
78+
<Message Text="Project File Name" />
79+
<Exec Command="dotnet run --project $(TypeCatalogProjectFilePath) $(CorePsTypeCatalogFilePath) $(RefAssemblyFilePath) "/>
80+
</Target>
81+
3282
</Project>

0 commit comments

Comments
 (0)
0