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

InvalidProjectFileException thrown for shared projects (.shproj) when doing a workload restore on Linux #41000

Open
GaijinFizz opened this issue May 19, 2024 · 2 comments
Assignees
Labels
Area-Workloads untriaged Request triage from a team member

Comments

@GaijinFizz
Copy link

GaijinFizz commented May 19, 2024

Describe the bug

When running dotnet workload restore on Ubuntu, the command will throw an InvalidProjectFileException on shared projects (.shproj file)

To Reproduce

Create a new solution including a Shared Project, and run dotnet workload restore on Ubuntu 24.04.

Exceptions (if any)

sylvain@ubuntu:~/MyProject$ dotnet workload restore
Unhandled exception: Microsoft.Build.Exceptions.InvalidProjectFileException: The imported file "$(MSBuildExtensionsPath32)/Microsoft/VisualStudio/v$(VisualStudioVersion)/CodeSharing/Microsoft.CodeSharing.Common.Default.props" does not exist and appears to be part of a Visual Studio component. This file may require MSBuild.exe in order to be imported successfully, and so may fail to build in the dotnet CLI. /home/sylvain/MyProject/MySharedProject/MySharedProject.shproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1](IElementLocation elementLocation, String resourceName, T1 arg0)
at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List1& imports)
at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List1& projects, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator4.Evaluate(IEvaluatorData4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary1 environmentProperties, ILoggingService loggingService, IItemFactory2 itemFactory, IToolsetProvider toolsetProvider, IDirectoryCacheFactory directoryCacheFactory, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable1 projectLoadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory)
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, Nullable1 projectLoadSettings, EvaluationContext evaluationContext, IDirectoryCacheFactory directoryCacheFactory, Boolean interactive)
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion) at Microsoft.DotNet.Workloads.Workload.Restore.WorkloadRestoreCommand.RunTargetToGetWorkloadIds(IEnumerable1 allProjects)
at Microsoft.DotNet.Workloads.Workload.Restore.WorkloadRestoreCommand.Execute()
at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

Further technical details

  • Include the output of dotnet --info
    sylvain@ubuntu:~/MyProject$ dotnet --info
    .NET SDK:
    Version: 8.0.300
    Commit: 326f6e68b2
    Workload version: 8.0.300-manifests.c1c70047
    MSBuild version: 17.10.4+10fbfbf2e

Runtime Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: linux-x64
Base Path: /home/sylvain/.dotnet/sdk/8.0.300/

.NET workloads installed:
There are no installed workloads to display.

Host:
Version: 8.0.5
Architecture: x64
Commit: 087e15321b

.NET SDKs installed:
8.0.300 [/home/sylvain/.dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.5 [/home/sylvain/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.5 [/home/sylvain/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/home/sylvain/.dotnet]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels May 19, 2024
@GaijinFizz GaijinFizz changed the title InvalidProjectFileException thrown on Linux for shared projects (.shproj) when doing a workload restore InvalidProjectFileException thrown for shared projects (.shproj) when doing a workload restore on Linux May 19, 2024
@Forgind
Copy link
Member

Forgind commented May 28, 2024

Per the error messsage:
...appears to be part of a Visual Studio component. This file may require MSBuild.exe in order to be imported successfully, and so may fail to build in the dotnet CLI.

Building it with the SDK isn't currently supported. If we can't evaluate it, we can't do a workload restore that includes it either. If there's a shproj that actually does require workloads (directly or indirectly), we couldn't do a workload restore properly, which means failing is expected and desired.

What kind of action are you looking for in this case?

@GaijinFizz
Copy link
Author

GaijinFizz commented May 29, 2024

I run the command at the solution level so I expected my shared projects to be ignored (they just hold files, nothing to build) and all the other supported projects' workloads to be restored, the same behaviour as on Windows.

Edit: sorry I re-tested on Windows and I see the same error as on Linux. But yes I would have expected that the restore would be triggered for the projects that can have a worload restored and it would ignore the shared projects.

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

No branches or pull requests

2 participants