Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build Solution that contains multi-targeted projects and using ArtifactsPath with IncludeProjectNameInArtifactsPaths set to false #45513

Open
trimblefelchlin opened this issue Dec 17, 2024 · 6 comments
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member
Milestone

Comments

@trimblefelchlin
Copy link

Description

I am trying to utilize the newest feature Simplified Artifacts Output. I want to exclude the project name from the path as to make it a more simplified structure. The issue is that when I do so and my solution contains a project that is multi-targeted it fails to add Multi-Targeted project frameworks to project.assets.json.

Error

src\Artifacts\obj\project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project.

obj folder structure

Image

https://learn.microsoft.com/en-us/dotnet/core/sdk/artifacts-output

Reproduction Steps

  • Solution that contains .NET 8 projects and at least one project that is multi-target. For example NET 8 and netstandard2.0
  • Add the following to Directory.Build.props
<PropertyGroup>
	<ArtifactsPath>$(SolutionDir)Artifacts\</ArtifactsPath>
	<IncludeProjectNameInArtifactsPaths>false</IncludeProjectNameInArtifactsPaths>
</PropertyGroup>
  • Attempt to build project

Configuration

  • Solution is .NET 8.0
  • A couple projects are .NET 8 - Windows
  • A couple projects are multi-targeted (.NET 8 and netstandard2.0)
  • Architecture is x64
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Dec 17, 2024
@marcpopMSFT
Copy link
Member

@nkolev92 @dsplaisted this appears to be an interesting use case for ArtifactsPath. Mind chatting to see what options there are here?

@marcpopMSFT marcpopMSFT added this to the Discussion milestone Dec 17, 2024
@marcpopMSFT
Copy link
Member

Is the best workaround to try to set ProjectAssetsFile to a unique directory per project/TFM and would that actually work? I'm not sure that's been tested.

@trimblefelchlin
Copy link
Author

It seems to not generate the project.assets.json at all, so I believe it wouldn't find anything.

Image

@trimblefelchlin
Copy link
Author

I have tried setting the following to just get the bin folder to all be in one place but it brings forth a handful of other issues.

        <ArtifactsOutputPath>$(SolutionDir)Artifacts</ArtifactsOutputPath>
        <UseArtifactsOutput>true</UseArtifactsOutput>
        <BaseOutputPath>$(ArtifactsOutputPath)\</BaseOutputPath>

@trimblefelchlin
Copy link
Author

We are hoping to get a folder with all build artifacts into one folder. We run tests in an Azure Hosted Agent but there is only so much space. With transitive dependencies throughout we are running into a space issue when downloading build artifacts for running tests. If I can accomplish this I am able to shrink the artifacts folder to more then half the size. We have another solution that would also benefit greatly from a centralized output directory. In theory it should help speed up the build process as well.

@dsplaisted
Copy link
Member

You can't use the same intermediate output path for multiple projects, because there needs to be a separate project.assets.json file for each project. Ideally, the name of the assets file would be different for each project (see this issue), but I think that's not likely to change.

You can use the same output path for multiple projects, but there are various issues you have to watch out for. Each different project will be trying to write its dependencies to the same folder, so shared dependencies will git written multiple times, and you might hit file copy errors if projects are being built in parallel. You also probably need to make sure that all of the projects use the same versions of their dependencies, otherwise the version of a dependency that's copied will depend on which project happened to be built last.

Since you would need to customize the output paths yourself, I'm not sure if the artifacts output layout setting would help you much in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants