razor: ViewComponents called with the vc taghelper are broken on 7.0.3

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

View Components aren’t called properly when building the project with .NET SDK 7.0.200. The tags are instead left on the page as a regular HTML tag. In some cases, passing arguments to the HTML tag results in error CS1503: Argument 3: cannot convert from 'method group' to 'object?'

This is likely a result of the newest SDK using MSBuild version 17.5.0-preview-23061-01+040e2a90e for .NET. I’m not sure a preview version of MSBuild was meant to leak into the production CLI.

Do not that I didn’t update MSBuild separately, this is just what came with the 7.0.200 SDK.

Expected Behavior

View Components should work

Steps To Reproduce

Take any simple view component test repo, build and run it using MSBuild 17.5.0-preview-23061-01+040e2a90e

Exceptions (if any)

No response

.NET Version

7.0.200

Anything else?

Using dotnet publish; this issue started surfacing on our build server. Using ASP.NET Core 7.0.2, but updating to 7.0.3 didn’t seem to fix the issue.

.NET SDK:
 Version:   7.0.200
 Commit:    534117727b

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.200/

Host:
  Version:      7.0.3
  Architecture: x64
  Commit:       0a2bda10e8

.NET SDKs installed:
  3.0.103 [/usr/share/dotnet/sdk]
  3.1.416 [/usr/share/dotnet/sdk]
  5.0.404 [/usr/share/dotnet/sdk]
  6.0.300 [/usr/share/dotnet/sdk]
  7.0.200 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

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

Download .NET:
  https://aka.ms/dotnet/download```

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 21
  • Comments: 53 (4 by maintainers)

Commits related to this issue

Most upvoted comments

We are aware of this regression and working to port our fix to 17.5.2 and 7.0.202.

https://github.com/dotnet/razor/pull/8328

Exactly the same issue. Build with 7.0.200, any <vc: tags in .cshtml are not working. 7.0.103 has no issue. Are you really done releasing or experimenting with us? How can the preview version be released 😦

Update: rolling back the SDK on the build agent to 7.0.103 fixes this issue. 7.0.200 seems broken w/r to ViewComponents due to the preview MSBuild version.

I just updated:

  • SDK: 7.0.202, 6.0.407
  • runtime: 7.0.4, 6.0.15
  • VS for Mac: 17.5.2 (build 14)

and the problem is gone…

Is the problem resolved in Azure DevOps yet? I can see it’s fixed in Visual Studio but I think the problem still happens if you build using Azure DevOps.

Just to toss my experience on here.

Pinning to a prior version of the SDK using a global.json file fixes things when working locally. However, publishing the application still stops all <vc style usages to totally stop working.

There is no viable workaround that allows us to publish applications. Currently haunting all deployments for > 45 of our customer applications

Another workaround is to add the global.json file to the solution/project to specify the SDK. We went back to use the previous stable version (7.0.102-103) using that instead of removing the SDK did it for us.

Not fixed in Azure DevOps. I just tried it and the agent hasn’t been updated yet, the sdk for the win2022 is still 7.0.201. Agent description page : https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md

@kanadaj Ok, this is a fun one, our repository had the structure of

/ /src /src/projects

Our solution file was in the /src folder, we had put the global.json there, which fixed locally etc. But didn’t work with GitHub Actions.

Putting it in the root still allowed the local stuff to work, AND fixed it on GitHub Actions for now. The part I bolded from the docs here was what escaped my management

The .NET SDK looks for a global.json file in the current working directory (which isn’t necessarily the same as the project directory) or one of its parent directories.

Today’s update didn’t fix anything. I’m now at version 17.5.1

Microsoft Visual Studio Community 2022 Version 17.5.1 VisualStudio.17.Release/17.5.1+33424.131

ASP.NET and Web Tools 17.5.317.37931

Looking forward to 17.5.2

Thanks @kanadaj for the response. I tried with the global.json file setting the version you mentioned and even a lower to 6.0.406 without luck. I’m trying to uninstall .NET 7.0.200 version, however, it says that I cannot uninstall it because it was installed with VS.

I tried to uninstall it from VS and it warnings me that all dependent features of .NET will be removed, I’m wondering if that will uninstall everything. Have you faced this issue with uninstalling a SDK?

Exactly same issue. Build with 7.0.200, any <vc: tags in .cshtml are not working. 7.0.103 has no issue.