Skip to content

Commit 4e47deb

Browse files
committed
Fix and refactor generator for p2p ref and tools
1 parent e332907 commit 4e47deb

File tree

2 files changed

+67
-21
lines changed

2 files changed

+67
-21
lines changed

tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator.Console/ExtensionsMetadataGenerator.Console.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@
1616
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
1717
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" />
1818
</ItemGroup>
19+
20+
<!-- workaround for https://github.com/Microsoft/msbuild/issues/2399 -->
21+
<Target Name="WorkaroundMSBuildIssue2399" BeforeTargets="GetTargetFrameworkProperties">
22+
<PropertyGroup>
23+
<ReferringTargetFramework>$(TargetFramework)</ReferringTargetFramework>
24+
</PropertyGroup>
25+
</Target>
26+
1927
</Project>
Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,70 @@
11
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="UpdateRuntimeAssemblies">
22
<Import Project="..\..\build\metadatagenerator.props" />
3+
34
<PropertyGroup>
45
<Version>4.0.2</Version>
56
<OutputType>Library</OutputType>
67
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
78
<AssemblyName>Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator</AssemblyName>
89
<RootNamespace>Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator</RootNamespace>
9-
<BuildOutputTargetFolder>tools</BuildOutputTargetFolder>
10+
<IncludeBuildOutput>false</IncludeBuildOutput>
11+
<IsPackable>true</IsPackable>
12+
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
13+
</PropertyGroup>
14+
15+
<!-- MSBuild extension props -->
16+
<PropertyGroup>
1017
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1118
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1219
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
13-
<IsPackable>true</IsPackable>
14-
<BeforePack>PackReferenceAssemblies</BeforePack>
15-
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
20+
<DevelopmentDependency>true</DevelopmentDependency>
1621
</PropertyGroup>
1722

1823
<ItemGroup>
19-
<ConsoleProject Include="..\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.Console.csproj" />
24+
<!-- Explicitly set TFM to net6.0 as auto-resolution will fail with incompatible TFM -->
25+
<ProjectReference
26+
Include="../ExtensionsMetadataGenerator.Console/ExtensionsMetadataGenerator.Console.csproj"
27+
ReferenceOutputAssembly="false"
28+
PrivateAssets="all"
29+
Private="false"
30+
SetTargetFramework="TargetFramework=net6.0"
31+
Condition="'$(TargetFramework)' == 'netstandard2.0'"/>
2032
</ItemGroup>
2133

22-
<Target Name="BuildGeneratorConsole" Condition="'$(TargetFramework)' == 'netstandard2.0'" AfterTargets="Build">
23-
<MSBuild Projects="@(ConsoleProject)" Targets="Restore;Build" Properties="Configuration=$(Configuration);Platform=$(Platform);TargetFramework=netcoreapp2.0;OutputPath=$(OutputPath)\generator" />
34+
<Target Name="_IncludeConsoleReferences" BeforeTargets="AssignTargetPaths" Condition="'$(TargetFramework)' == 'netstandard2.0'">
35+
<MSBuild Projects="@(ProjectReference)" Targets="GetTargetPath">
36+
<Output TaskParameter="TargetOutputs" PropertyName="_ConsoleOutputPath" />
37+
</MSBuild>
38+
39+
<PropertyGroup>
40+
<_ConsoleOutputPath>$([System.IO.Path]::GetDirectoryName($(_ConsoleOutputPath)))</_ConsoleOutputPath>
41+
</PropertyGroup>
42+
43+
<ItemGroup>
44+
<_ConsoleFiles Include="$(_ConsoleOutputPath)/*" />
45+
<None Include="@(_ConsoleFiles)" Link="generator/%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
46+
</ItemGroup>
2447
</Target>
2548

2649
<ItemGroup>
27-
<Content Include="Targets\**\*">
28-
<Pack>true</Pack>
29-
<PackagePath>build</PackagePath>
30-
</Content>
50+
<Content Include="Targets/**" Pack="true" PackagePath="build" />
3151
</ItemGroup>
3252

3353
<Target Name="UpdateRuntimeAssemblies" BeforeTargets="Build">
3454
<Exec Command="pwsh ./updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Unix' "/>
35-
<Exec Command="powershell.exe -command .\updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Windows_NT' "/>
55+
<Exec Command="powershell.exe -command ./updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Windows_NT' "/>
3656
</Target>
3757

38-
<Target Name="PackReferenceAssemblies">
58+
<Target Name="_CollectRuntimeDependencies" DependsOnTargets="_ComputeTargetFrameworkItems" BeforeTargets="_GetPackageFiles">
59+
<MSBuild Projects="@(_InnerBuildProjects)" Targets="GetOutputFiles">
60+
<Output TaskParameter="TargetOutputs" ItemName="_InnerOutputFiles" />
61+
</MSBuild>
62+
3963
<ItemGroup>
40-
<Content Include="$(OutputPath)\netstandard2.0\generator\*">
41-
<Pack>true</Pack>
42-
<PackagePath>tools\netstandard2.0\generator</PackagePath>
43-
</Content>
44-
<Content Include="$(OutputPath)\netstandard2.0\*.dll" Exclude="**\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll">
45-
<Pack>true</Pack>
46-
<PackagePath>tools\netstandard2.0\</PackagePath>
47-
</Content>
64+
<Content
65+
Include="@(_InnerOutputFiles)"
66+
Pack="true"
67+
PackagePath="tools/%(_InnerOutputFiles.PackagePath)" />
4868
</ItemGroup>
4969
</Target>
5070

@@ -73,6 +93,24 @@
7393
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
7494
<PackageReference Include="System.Runtime.Loader">
7595
<Version>4.3.0</Version>
96+
<PrivateAssets>all</PrivateAssets>
7697
</PackageReference>
7798
</ItemGroup>
99+
100+
<Target Name="RemoveFrameworkDependencies" AfterTargets="_WalkEachTargetPerFramework">
101+
<ItemGroup>
102+
<_FrameworkAssemblyReferences Remove="@(_FrameworkAssemblyReferences)" />
103+
</ItemGroup>
104+
</Target>
105+
106+
<Target Name="GetOutputFiles" Returns="@(_OutputFiles)">
107+
<ItemGroup>
108+
<_OutputFiles Include="$(OutputPath)**/*.dll" Exclude="$(OutputPath)**/Microsoft.Build.*.dll" />
109+
<_OutputFiles Include="$(OutputPath)**/*.dll.config" />
110+
<_OutputFiles Include="$(OutputPath)**/*.exe" />
111+
<_OutputFiles Include="$(OutputPath)**/*.json" />
112+
<_OutputFiles Update="@(_OutputFiles)" PackagePath="$([System.IO.Path]::Combine($(TargetFramework), %(RecursiveDir)))" />
113+
</ItemGroup>
114+
</Target>
115+
78116
</Project>

0 commit comments

Comments
 (0)