Skip to content

Commit 75f4cc3

Browse files
Check dependencies of Microsoft.DotNet.MSBuildSdkResolver against baseline (#37381)
As pointed out in dotnet/msbuild#9439 (comment), we have to be careful when changing the set of dependencies of the SDK resolver assembly as it may impact binding redirects in MSBuild's app.config. This PR adds a simple post-build step which compares the dependencies of the just-built assembly with a baseline. Co-authored-by: Rainer Sigwald <[email protected]>
1 parent cdd2b9c commit 75f4cc3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,33 @@
132132
</ItemGroup>
133133
</Target>
134134

135+
<Target Name="VerifyDependencies" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" AfterTargets="Build">
136+
<ResolveAssemblyReference AssemblyFiles="$(TargetPath)" SearchPaths="" AutoUnify="true">
137+
<Output TaskParameter="ResolvedDependencyFiles" ItemName="ResolvedDependencies"/>
138+
</ResolveAssemblyReference>
139+
140+
<ItemGroup>
141+
<ExpectedDependencies Include="Microsoft.Deployment.DotNet.Releases, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
142+
<ExpectedDependencies Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" />
143+
<ExpectedDependencies Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
144+
<ExpectedDependencies Include="System.Collections.Immutable, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
145+
<ExpectedDependencies Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
146+
<ExpectedDependencies Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
147+
<ExpectedDependencies Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
148+
<ExpectedDependencies Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
149+
</ItemGroup>
150+
151+
<!-- Check that the dependencies of the output assembly match our expectations -->
152+
<PropertyGroup>
153+
<ResolvedDependenciesList>@(ResolvedDependencies->'%(FusionName)')</ResolvedDependenciesList>
154+
<ExpectedDependenciesList>@(ExpectedDependencies->'%(Identity)')</ExpectedDependenciesList>
155+
<DependencyMismatchErrorText>This may have consequences for MSBuild.exe binding redirects, please get signoff from the MSBuild team.</DependencyMismatchErrorText>
156+
</PropertyGroup>
157+
158+
<Error Text="$(AssemblyName) is expected to depend on %(ExpectedDependencies.Identity). $(DependencyMismatchErrorText)"
159+
Condition="!($([System.String]::Copy('$(ResolvedDependenciesList)').Contains('%(ExpectedDependencies.Identity)')))" />
160+
<Error Text="$(AssemblyName) is not expected to depend on %(ResolvedDependencies.FusionName). $(DependencyMismatchErrorText)"
161+
Condition="!($([System.String]::Copy('$(ExpectedDependenciesList)').Contains('%(ResolvedDependencies.FusionName)')))" />
162+
</Target>
163+
135164
</Project>

0 commit comments

Comments
 (0)