Skip to content

NuspecHasTheSameVersionsWithPackagesConfig

Igor Manushin edited this page Mar 13, 2017 · 2 revisions

What this rule is about?

Rule checks, that nuspec files has the same dependencies with packages.config file. However it validates only simple dependency form, e.g. dependencies like "1.0.0". Nupsec has extended format to add restrictions, for example - version="[1,2)" (only 1.* versions are supported)

Why should I enable this rule?

Sometimes nuspec dependencies are updated manually, so developer can forget to set new version in the nuspec file. Therefore, nuget package will require to library A, however libraries inside nupkg file will require version B.

How to enable/configure this rule

<Rules>
...
<NuspecHasTheSameVersionsWithPackagesConfig enabled="false">
  <Nupspec>
    <!--One simple nuspec file. Relative and absolute pathes are supported.-->
    <Path>NuspecFiles/MyPackage.nuspec</Path>
  </Nupspec>
  <Nupspec>
    <!--Mask-based nuspec file pattern. SolutionCop will resolve folder '../../NuspecFiles/' and then will try to find all files *.nuspec in this directory and in all subdirectories (see .Net option 'SearchOption.AllDirectories')-->
    <Path>../../NuspecFiles/*.nuspec</Path>
  </Nupspec>
  <Nupspec>
    <Path>MyPackage.nuspec</Path>
    <!--Target package will be ignored for current nuspec pattern only-->
    <ExcludePackageId packageId="package-id" />
    <!--This project will be ignored for current nuspec pattern only. All these declarations are the same: 'myProject.csproj', 'myProject', MYPROJECT-->
    <ExcludePackagesOfProject projectName="ProjectWithAnotherReferences.csproj" />
  </Nupspec>
  <!--Target package will be ignored for all nuspec files-->
  <ExcludePackagesOfProject projectName="ProjectWithAnotherReferences.csproj" />
  <!--This project will be ignored by all nuspec files. All these declarations are the same: 'myProject.csproj', 'myProject', MYPROJECT-->
  <ExcludePackageId packageId="package-id" />
</NuspecHasTheSameVersionsWithPackagesConfig>
...
</Rules>