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

NPM version of switch-to-packages and -projects broken after latest VS update #93

Open
WJ89 opened this issue Mar 24, 2021 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@WJ89
Copy link

WJ89 commented Mar 24, 2021

I am using the NPM version due to having full .NET framework projects in my solution.
After updating to the latest version of Visual Studio (16.9.2) all projects are failing to switch with the following error:

The project '{pathTo/myProj.csproj}' could not be loaded: System.InvalidOperationException: Not a project: {pathTo/myProj.csproj} ---> Microsoft.Build.Exceptions.InvalidProjectFileException: Invalid static method invocation syntax: "[MSBuild]::AreFeaturesEnabled('16.8')". Method '[MSBuild]::AreFeaturesEnabled' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). Check that all parameters are defined, are of the correct type, and are specified in the right order. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets
{stack trace}

This is fixed if I delete the offending "AreFeaturesEnabled" PropertyGroup in Microsoft.Common.CurrentVersion.targets,
any ideas why this problem is occurring?

@WJ89
Copy link
Author

WJ89 commented Mar 24, 2021

Full stack trace:
The project '{pathTo/myProj.csproj}' could not be loaded: System.InvalidOperationException: Not a project: {pathTo/myProj.csproj} ---> Microsoft.Build.Exceptions.InvalidProjectFileException: Invalid static method invocation syntax: "[MSBuild]::AreFeaturesEnabled('16.8')". Method '[MSBuild]::AreFeaturesEnabled' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). Check that all parameters are defined, are of the correct type, and are specified in the right order. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1,T2](IElementLocation elementLocation, String resourceName, T1 arg0, T2 arg1)
at Microsoft.Build.Evaluation.Expander2.Function1.Execute(Object objectInstance, IPropertyProvider1 properties, ExpanderOptions options, IElementLocation elementLocation) at Microsoft.Build.Evaluation.Expander2.PropertyExpander1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
at Microsoft.Build.Evaluation.Expander2.PropertyExpander1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem) at Microsoft.Build.Evaluation.Expander2.PropertyExpander1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
at Microsoft.Build.Evaluation.Expander2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation) at Microsoft.Build.Evaluation.ConditionEvaluator.ConditionEvaluationState2.ExpandIntoString(String expression)
at Microsoft.Build.Evaluation.StringExpressionNode.GetExpandedValue(IConditionEvaluationState state)
at Microsoft.Build.Evaluation.StringExpressionNode.CanBoolEvaluate(IConditionEvaluationState state)
at Microsoft.Build.Evaluation.GenericExpressionNode.Evaluate(IConditionEvaluationState state)
at Microsoft.Build.Evaluation.ConditionEvaluator.EvaluateConditionCollectingConditionedProperties[P,I](String condition, ParserOptions options, Expander2 expander, ExpanderOptions expanderOptions, Dictionary2 conditionedPropertiesTable, String evaluationDirectory, ElementLocation elementLocation, ILoggingService loggingServices, BuildEventContext buildEventContext, IFileSystem fileSystem, ProjectRootElementCacheBase projectRootElementCache)
at Microsoft.Build.Evaluation.Evaluator4.EvaluateConditionCollectingConditionedProperties(ProjectElement element, String condition, ExpanderOptions expanderOptions, ParserOptions parserOptions, ProjectRootElementCacheBase projectRootElementCache) at Microsoft.Build.Evaluation.Evaluator4.EvaluatePropertyGroupElement(ProjectPropertyGroupElement propertyGroupElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at Dnt.Commands.ProjectExtensions.LoadProject(String projectPath, IDictionary2 globalProperties) in C:\projects\dnt\src\Dnt.Commands\ProjectExtensions.cs:line 55
--- End of inner exception stack trace ---
at Dnt.Commands.ProjectExtensions.LoadProject(String projectPath, IDictionary`2 globalProperties) in C:\projects\dnt\src\Dnt.Commands\ProjectExtensions.cs:line 62
at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.SwitchToProjects(ReferenceSwitcherConfiguration configuration, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 63

@lucasrossoni
Copy link

I have the same problem.

Apparently, it changes the reference of the solution, but does not add the project to the solution

@RicoSuter RicoSuter added the help wanted Extra attention is needed label Apr 13, 2021
@RicoSuter
Copy link
Owner

Can you clone the repo and try to find a fix locally and create a PR?

@ShaharPrishMSFT
Copy link
Contributor

ShaharPrishMSFT commented Apr 20, 2021

The problem is that there are missing assemblies in:
C:\Program Files\dotnet\sdk\5.0.300-preview.21180.15
Which is what DNT gets targeted to.
So far found 2 assemblies missing, but this does't seem to be the issue - I am thiking that something changed in the assembly load code that is making these not found.

"C:\Program Files\dotnet\sdk\5.0.300-preview.21180.15\en\Microsoft.Build.resources.dll"
Which is there, under the EN folder, but is sought in the directory above.

Microsoft.NET.Sdk.WorkloadManifestReader
This one is missing. It does have resources, but the DLL itself is missing from the 5.0.300 folder. Note that this is probably being loaded from a different location - I can't find it in any of the folders.

@pixellos
Copy link

For me same problem - after VS2022 is installed everything blow up.

@marioQueiros-infotrack
Copy link

For me same problem - after VS2022 is installed everything blow up.

Same thing for me.
Says that the csproj is not a project
System.InvalidOperationException: Not a project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants