Closed Joren-Thijs-KasparSolutions closed 2 years ago
Small update: after further debugging with the help of a coworker we have determined the root cause might be the underlying OS.
When we change the underlying OS in our azure pipeline to be windows-2022
then restore succeeds but when we change it back to ubuntu-latest
the build fails. An obvious culprit would seem case-sensitivity between these two but renaming Directory.build.props
to directory.build.props
does not resolve the issue.
We also updated our pipeline to run our test job inside the mcr.microsoft.com/dotnet/sdk:6.0
container image to avoid having to install the sdk manually every time.
Our azure pipelines file now looks like this:
pool:
vmImage: "ubuntu-latest"
variables:
DOCKER_BUILDKIT: 1
stages:
- stage: Test
jobs:
- job: Test
container: mcr.microsoft.com/dotnet/sdk:6.0
steps:
- task: NuGetAuthenticate@0
- task: DotNetCoreCLI@2
inputs:
command: "test"
The correct casing, as documented: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022
is Directory.Build.props
.
For what it's worth, NuGet get project and package information from MSBuild, NuGet does not read MSBuild files itself, so https://github.com/dotnet/msbuild would have been the better place for this issue.
@zivkan Thank you so much! I feel very stupid now😅
NuGet Product Used
dotnet.exe
Product Version
.NET SDK Version: 6.0.101 Commit: ef49f6213a Runtime Environment: OS Name: debian OS Version: 11 OS Platform: Linux RID: debian.11-x64 Base Path: /usr/share/dotnet/sdk/6.0.101/ Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc .NET SDKs installed: 6.0.101 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App] NuGet Command Line 6.0.0.280
Worked before?
I works locally and in Visual Studio
Impact
It's more difficult to complete my work
Repro Steps & Context
Context
I recently updated our NET5 solution to NET6. To do this I introduced a Directory.build.props file where i moved all the common properties to.
Our domain project for example has an empty csproj file now
Other projects still have other properties or package refrences.
The solution structure is as follows
Building this solution works fine in Visual Studio and in the terminal with VS Code. Both on Windows and in Linux.
However when trying to build this code inside a docker container or in the Azure pipeline cli it fails. Below the Test step will attempt to restore the project and fail with
/usr/share/dotnet/sdk/6.0.101/NuGet.targets(130,5): error : Invalid framework identifier ''. [/src/Kaspar123.Case.sln
azure-pipelines.yml
Docker example:
This seems similar to this issue https://github.com/NuGet/Home/issues/10423#issuecomment-803608441 And this post https://stackoverflow.com/questions/67115762/azuredevops-pipeline-dotnetcorecli-restore-ignores-directory-build-props-file
But none ever propose a fix to make nuget use the Directory.build.props file.
Is there a reason for this behaviour and is there a fix? I don't want to move the TargetFramework properties back to individual csproj files because this causes dulpicate configuration work.
Verbose Logs