I have a solution that has two class libraries lets say A.csproj and B.csproj. Library A is in .NET Framework 4.8 and library B is in .netstandard2.0. A is using GitVersion.Msbuild 5.10.3 and if I try to use the same package version for library B then the build fails in the azure pipeline. But if I use GitVersion.Msbuild 5.10.2 (or any other lower version) for library B, then the build gets successfully run in the azure pipeline.
I am using below import statements in the csproj files.
For .NET Framework:
<Import Project="..\common\packages\GitVersion.MsBuild.5.10.3\build\GitVersion.MsBuild.props" Condition="Exists('..\common\packages\GitVersion.MsBuild.5.10.3\build\GitVersion.MsBuild.props')" />
For .netstandard2.0:
<Import Project="..\common\packages\GitVersion.MsBuild.5.10.2\build\GitVersion.MsBuild.props" Condition="Exists('..\common\packages\GitVersion.MsBuild.5.10.2\build\GitVersion.MsBuild.props')"/>
While restoring the packages only GitVersion.MsBuild.5.10.3 folder is created locally for .NET Framework library but GitVersion.MsBuild.5.10.2 is not getting created locally for .netstandard2.0 library. If this folder gets created then the solution will get build in both local and azure pipeline.
So in summary I want to use two different versions of GitVersion.Msbuild:- version 5.10.3 for .NET Framework and version 5.10.2 for .netstandard2.0 libaries. I want GitVersion.MsBuild.5.10.2 package folder also to be created inside ..\common\packages. P.S.: Both the libraries are present in the same solution.
I have tried manually adding the GitVersion.MsBuild.5.10.2 folder in ..\common\packages but that is not the right way and if I remove it, while restoring the nuget packages doesn't get created for .netstandard libraries. Even I tried using the dotnet restore command from the command line that also did not create the package folder.
It should not require you to install multiple version of the same package and also having .NET Framework 4.8 and .netstandard2.0 projects should not create any problem. You have to build and restore the .netstandard libraries separately in the azure pipeline. In the yml file just add the below task:
- task: DotNetCoreCLI@2
displayName: 'Restore netstandard libraries'
inputs:
command: 'restore'
projects: '**/*.csproj'
nugetConfigPath: '$(ProjectName)\$(NugetConfigPath)'
env:
ARTIFACTORY__API_KEY: $(ARTIFACTORY__API_KEY)