dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

dotnet store fails because of content files (Microsoft.NET.ComposeStore.targets(345,5): error MSB3024) #32942

Open gotztibor opened 1 year ago

gotztibor commented 1 year ago

Description

With the attached simple example project the dotnet store command fails upon creation the runtime package store. ExampleContent.zip According to the attached detailed build log.zip, it seems so, that the following is causing the problem:

"C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ComposeStore.targets(345,5): error MSB3024: Could not copy the file "d:\Example\ExampleContent\ExampleContent\Config\ConfigExample.json" to the destination file "d:\rps\x64\net6.0\", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. "

The performed command was the following: dotnet store /v:diag --framework net6.0 --runtime win-x64 --framework-version 6.0.16 --skip-optimization --output d:\rps --manifest ExampleContent.csproj

Configuration

.net sdk: 6.0.408 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk]

.net runtime: Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

os: Windows 10 21H2 19044.2965 architecture: x64

Other information

The symptom is really the same, if there are nuget packages in the dependency tree with some "files" in the "contentFiles\any" section of the package.

ghost commented 1 year ago

Tagging subscribers to this area: @vitek-karas, @agocke, @vsadov See info in area-owners.md if you want to be subscribed.

Issue Details
### Description With the attached simple example project the dotnet store command fails upon creation the runtime package store. [ExampleContent.zip](https://github.com/dotnet/core/files/11599121/ExampleContent.zip) According to the attached detailed build [log.zip](https://github.com/dotnet/core/files/11599126/log.zip), it seems so, that the following is causing the problem: "C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ComposeStore.targets(345,5): error MSB3024: Could not copy the file "d:\Example\ExampleContent\ExampleContent\Config\ConfigExample.json" to the destination file "d:\rps\x64\net6.0\", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. " The performed command was the following: **dotnet store /v:diag --framework net6.0 --runtime win-x64 --framework-version 6.0.16 --skip-optimization --output d:\rps --manifest ExampleContent.csproj** ### Configuration **.net sdk:** 6.0.408 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk] **.net runtime:** Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] **os:** Windows 10 21H2 19044.2965 **architecture:** x64 ### Other information The symptom is really the same, if there are nuget packages in the dependency tree with some "files" in the "contentFiles\any" section of the package.
Author: gotztibor
Assignees: -
Labels: `area-Host`, `untriaged`, `needs-area-label`
Milestone: -
gotztibor commented 1 year ago

By changing the dotnet/sdk like this would lay out the content files in a simplified way.

Please could someone confirm, that the modification is not absolutely against any design decision and it has sense to raise a pull request.

dsplaisted commented 1 year ago

I think this is not supported.

The project file that you pass to the dotnet store command is referred to as a "Package Store Manifest". It is supposed to simply be a list of PackageReference items, and other normal project file elements such as Content aren't supported.

The package store manifest isn't meant to be built as a normal project. What's the reason for trying to have a Content item in it?

gotztibor commented 1 year ago

Sorry. I missed to mention, that the same would happen, if You have a "clean" package manifest file only referring some nuget packages but one from those or from the hierarchy contains "content" or "contentFiles". This case the store command will fail, as that is not generating the full destination path for these nuget elements correctly. The responsible msbuild target file from the SDK is the following: src\Tasks\Microsoft.NET.Build.Tasks\targets\Microsoft.NET.Publish.targets

I tried to create some solution as the following: Microsoft.NET.Publish.targets

The reason is, that for these kind of files the previously mentioned target file is not populating the DestinationSubPath property, and therefore the store command (Microsoft.NET.ComposeStore.targets / _CopyResolvedUnOptimizedFiles) would map them simply in a directory, and that is causing the build error.

dsplaisted commented 1 year ago

Is there a specific NuGet package that you were trying to use that has content files in it that we could use to test this?

You can probably work around this by excluding content assets, something like this:

<PackageReference Include="PackageName" Version="<Version>" ExcludeAssets="contentFiles" />