Skip to content

Commit d3360a6

Browse files
authored
Fix and refactor generator for p2p ref and tools (#10648)
* Fix and refactor generator for p2p ref and tools * Remove uneeded target * Suppress NU5128
1 parent 48712e8 commit d3360a6

File tree

1 file changed

+58
-15
lines changed

1 file changed

+58
-15
lines changed

tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/ExtensionsMetadataGenerator.csproj

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,66 @@
55
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
66
<AssemblyName>Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator</AssemblyName>
77
<RootNamespace>Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator</RootNamespace>
8-
<BuildOutputTargetFolder>tools</BuildOutputTargetFolder>
8+
<IncludeBuildOutput>false</IncludeBuildOutput>
9+
<IsPackable>true</IsPackable>
10+
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
11+
</PropertyGroup>
12+
13+
<!-- MSBuild extension props -->
14+
<PropertyGroup>
915
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1016
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1117
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
12-
<IsPackable>true</IsPackable>
13-
<BeforePack>PackReferenceAssemblies</BeforePack>
14-
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
18+
<DevelopmentDependency>true</DevelopmentDependency>
19+
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
1520
</PropertyGroup>
1621

1722
<ItemGroup>
18-
<ConsoleProject Include="..\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.Console.csproj" />
23+
<!-- Explicitly set TFM to net6.0 as auto-resolution will fail with incompatible TFM. -->
24+
<!-- https://github.com/Microsoft/msbuild/issues/2399 -->
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'"/>
1932
</ItemGroup>
2033

21-
<Target Name="BuildGeneratorConsole" Condition="'$(TargetFramework)' == 'netstandard2.0'" AfterTargets="Build">
22-
<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>
2347
</Target>
2448

2549
<ItemGroup>
26-
<Content Include="Targets\**\*" Pack="true" PackagePath="build" />
50+
<Content Include="Targets/**" Pack="true" PackagePath="build" />
2751
</ItemGroup>
2852

2953
<Target Name="UpdateRuntimeAssemblies" BeforeTargets="Build">
3054
<Exec Command="pwsh ./updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Unix' "/>
31-
<Exec Command="powershell.exe -command .\updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Windows_NT' "/>
55+
<Exec Command="powershell.exe -command ./updateruntimeassemblies.ps1" Condition=" '$(OS)' == 'Windows_NT' "/>
3256
</Target>
3357

34-
<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+
3563
<ItemGroup>
36-
<Content Include="$(OutputPath)\netstandard2.0\generator\*" Pack="true" PackagePath="tools\netstandard2.0\generator" />
3764
<Content
38-
Include="$(OutputPath)\netstandard2.0\*.dll"
39-
Exclude="**\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll"
65+
Include="@(_InnerOutputFiles)"
4066
Pack="true"
41-
PackagePath="tools\netstandard2.0\" />
67+
PackagePath="tools/%(_InnerOutputFiles.PackagePath)" />
4268
</ItemGroup>
4369
</Target>
4470

@@ -57,6 +83,23 @@
5783
</ItemGroup>
5884

5985
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
60-
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
86+
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" PrivateAssets="all" />
6187
</ItemGroup>
88+
89+
<Target Name="RemoveFrameworkDependencies" AfterTargets="_WalkEachTargetPerFramework">
90+
<ItemGroup>
91+
<_FrameworkAssemblyReferences Remove="@(_FrameworkAssemblyReferences)" />
92+
</ItemGroup>
93+
</Target>
94+
95+
<Target Name="GetOutputFiles" Returns="@(_OutputFiles)">
96+
<ItemGroup>
97+
<_OutputFiles Include="$(OutputPath)**/*.dll" Exclude="$(OutputPath)**/Microsoft.Build.*.dll" />
98+
<_OutputFiles Include="$(OutputPath)**/*.dll.config" />
99+
<_OutputFiles Include="$(OutputPath)**/*.exe" />
100+
<_OutputFiles Include="$(OutputPath)**/*.json" />
101+
<_OutputFiles Update="@(_OutputFiles)" PackagePath="$([System.IO.Path]::Combine($(TargetFramework), %(RecursiveDir)))" />
102+
</ItemGroup>
103+
</Target>
104+
62105
</Project>

0 commit comments

Comments
 (0)