@@ -138,6 +138,46 @@ describe('modules/manager/nuget/extract', () => {
138
138
expect ( res ) . toBeNull ( ) ;
139
139
} ) ;
140
140
141
+ it ( 'extracts msbuild sdk from the Import element' , async ( ) => {
142
+ const packageFile = 'sample.csproj' ;
143
+ const sample = `
144
+ <Project>
145
+ <PropertyGroup>
146
+ <TargetFramework>net7.0</TargetFramework> <!-- this is a dummy value -->
147
+ <NuspecFile>$(MSBuildThisFileDirectory)\tdlib.native.nuspec</NuspecFile>
148
+ <NuspecProperties>version=$(PackageVersion)</NuspecProperties>
149
+ </PropertyGroup>
150
+ <Import Project="Sdk.props" Sdk="My.Custom.Sdk" Version="1.2.3" />
151
+ </Project>
152
+ ` ;
153
+ const res = await extractPackageFile ( sample , packageFile , config ) ;
154
+ expect ( res ?. deps ) . toEqual ( [
155
+ {
156
+ depName : 'My.Custom.Sdk' ,
157
+ depType : 'msbuild-sdk' ,
158
+ currentValue : '1.2.3' ,
159
+ datasource : 'nuget' ,
160
+ } ,
161
+ ] ) ;
162
+ expect ( res ?. deps ) . toHaveLength ( 1 ) ;
163
+ } ) ;
164
+
165
+ it ( 'does not extract msbuild sdk from the Import element if version is missing' , async ( ) => {
166
+ const packageFile = 'sample.csproj' ;
167
+ const sample = `
168
+ <Project>
169
+ <PropertyGroup>
170
+ <TargetFramework>net7.0</TargetFramework> <!-- this is a dummy value -->
171
+ <NuspecFile>$(MSBuildThisFileDirectory)\tdlib.native.nuspec</NuspecFile>
172
+ <NuspecProperties>version=$(PackageVersion)</NuspecProperties>
173
+ </PropertyGroup>
174
+ <Import Project="Sdk.props" Sdk="My.Custom.Sdk" />
175
+ </Project>
176
+ ` ;
177
+ const res = await extractPackageFile ( sample , packageFile , config ) ;
178
+ expect ( res ) . toBeNull ( ) ;
179
+ } ) ;
180
+
141
181
it ( 'extracts dependency with lower-case Version attribute' , async ( ) => {
142
182
const contents = codeBlock `
143
183
<Project Sdk="Microsoft.NET.Sdk">
0 commit comments