Closed phenning closed 2 years ago
VB is not supported in .NET Core 3.1, the support was added in .NET 5, https://devblogs.microsoft.com/dotnet/visual-basic-winforms-apps-in-net-5-and-visual-studio-16-8/.
/cc: @KlausLoeffelmann @KathleenDollard
VB is not supported in .NET Core 3.1, the support was added in .NET 5, https://devblogs.microsoft.com/dotnet/visual-basic-winforms-apps-in-net-5-and-visual-studio-16-8/.
/cc: @KlausLoeffelmann @KathleenDollard
Support in the template was added in this PR, so it's been "supported" for quite some time.
It (netcoreapp3.1) got broken when you added support for VB Application Framework in this PR: https://github.com/dotnet/winforms/commit/8bec0f0c8ad2057f24fb1b003a5b3e696b02eccc
My PR fixes the brokenness IRT to 3.1 apparently not supporting VB Application Framework, thus the explicit parameter which is in the template.
"UseWindowsDesktopSdk": {
"type": "computed",
"value": "(Framework == \"netcoreapp3.1\")"
},
I think the confusion is here:
(From the link above: https://devblogs.microsoft.com/dotnet/visual-basic-winforms-apps-in-net-5-and-visual-studio-16-8/)
While .NET Core has had Visual Basic since the first release, and WinForms since it was released in .NET Core 3.1, it did not include the Application Framework library and WinForms Designer support Visual Basic programmers expect.
I read this as WinForms did support VB in netcoreapp3.1, but did not support the Application Framework library until net5.0
@phenning thank you for digging in.
I had a quick offline chat with @KlausLoeffelmann, and he straightened me - VB is supported from cli just not in VS.
@RussKie I think its just Application Framework isn't supported when targeting 3.1.
That appears to be the intent in both the blog posts and in all the previous updates to template.json. It's just that there was a slight authoring error in the template.json.
Its pretty apparent there is different expected behavior here since
3.1 uses <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
and 5.0+ uses <Project Sdk="Microsoft.NET.Sdk">
Yes, "Application Framework" is the keyword that I omitted from my earlier reply.
Verified on the .NET 7.0 Preview6 test pass build: 7.0.100-preview.6.22352.1, this issue is fixed that the .NET Core 3.1 VB WinForms project which created from VS can be built successfully now.
.NET version
7.0.100-preview.4.22252.9
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Only with netcoreapp3.1 SDK I believe.
Issue description
When creating a NET Core 3.1 WinForms app in VIsual Studio, an error is encountered:
1>------ Build started: Project: WinFormsApp5, Configuration: Debug Any CPU ------ 1>vbc : error BC30420: 'Sub Main' was not found in 'WinFormsApp5'. 1>Done building project "WinFormsApp5.vbproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is happening because the Program.vb is not being laid down by the template due to an incorrect condition in template.json When the same template is created on the command line via the following, the Program.vb is created, so no error results.
dotnet new winforms -f netcoreapp3.1 -lang VB
The following configuration is causing the errors: Since the TFM is netcoreapp3.1, UseWindowsDesktopSdkis set to true;
As a result of this, the ApplicationEvents, and other files are excluded:
However, the Program.vb is ALSO excluded:
This happens because skipAppModel is evaluated as false, but the condition above is a negation, so Program.vb is always excluded (hostIsCli == false) in this case, so this will always be false when run from Visual Studio "skipAppModel": { "type": "computed", "value": "(hostIsCli && !UseAppFramework)" }
Fix here would be to update the skipAppModel condition to:
"(UseWindowsDesktopSdk || (hostIsCli && !UseAppFramework))"
Steps to reproduce
Repro steps:
Build started... 1>------ Build started: Project: WinFormsApp5, Configuration: Debug Any CPU ------ 1>vbc : error BC30420: 'Sub Main' was not found in 'WinFormsApp5'. 1>Done building project "WinFormsApp5.vbproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========