@@ -201,35 +201,35 @@ public override void Initialize(AnalysisContext context)
201201 if ( options . TryGetValue ( "build_property.SourceControlInformationFeatureSupported" , out var sccSupported ) &&
202202 "true" . Equals ( sccSupported , StringComparison . OrdinalIgnoreCase ) )
203203 {
204- string ? repoCommit = default ;
205-
206- if ( ! options . TryGetValue ( "build_property.RepositoryCommit" , out repoCommit ) ||
207- string . IsNullOrWhiteSpace ( repoCommit ) )
208- {
209- ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingRepositoryCommit , null ) ) ;
210- repoCommit = default ;
211- }
212204
213205 if ( isPacking )
214206 {
207+ string ? repoCommit = default ;
208+
209+ if ( ! options . TryGetValue ( "build_property.RepositoryCommit" , out repoCommit ) ||
210+ string . IsNullOrWhiteSpace ( repoCommit ) )
211+ {
212+ ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingRepositoryCommit , null ) ) ;
213+ repoCommit = default ;
214+ }
215+
215216 if ( ! sourceLinkEnabled )
216217 ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingSourceLink , null ) ) ;
217218 // When packing, suggest reproducible builds by embedding untrack sources
218219 else if ( ! options . TryGetValue ( "build_property.EmbedUntrackedSources" , out var embedUntracked ) ||
219220 ! "true" . Equals ( embedUntracked , StringComparison . OrdinalIgnoreCase ) )
220221 ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingSourceEmbed , null ) ) ;
221- }
222- }
223-
224- if ( ! options . TryGetValue ( "build_property.RepositoryUrl" , out var repoUrl ) ||
225- string . IsNullOrWhiteSpace ( repoUrl ) )
226- ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingRepositoryUrl , null ) ) ;
227222
228- if ( ! options . TryGetValue ( "build_property.PackageProjectUrl" , out var projectUrl ) ||
229- string . IsNullOrWhiteSpace ( projectUrl ) ||
230- projectUrl == repoUrl )
231- ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingProjectUrl , null , repoUrl ) ) ;
223+ if ( ! options . TryGetValue ( "build_property.RepositoryUrl" , out var repoUrl ) ||
224+ string . IsNullOrWhiteSpace ( repoUrl ) )
225+ ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingRepositoryUrl , null ) ) ;
232226
227+ if ( ! options . TryGetValue ( "build_property.PackageProjectUrl" , out var projectUrl ) ||
228+ string . IsNullOrWhiteSpace ( projectUrl ) ||
229+ projectUrl == repoUrl )
230+ ctx . ReportDiagnostic ( Diagnostic . Create ( Descriptors . MissingProjectUrl , null , repoUrl ) ) ;
231+ }
232+ }
233233 } ) ;
234234 }
235235}
0 commit comments