Open JoeRobich opened 10 months ago
@JoeRobich I believe that is part of the WinForms VB Runtime not .Net Core, there have been some requests to move it and other parts of the VB Runtime down to Core since it would enable easier access from C# and allow VB code on Linux and Mac, but I have not seen any movement. There is very little in ApplicationBase (120 lines) but ApplicationBase.Info uses reflection on Windows to access Assembly and if you need that more work would be required.
Joey - please move this to the runtime repo when ready.
After doing a little more investigation, this isn't an issue for the Runtime or WinForms teams.
_MyType
should be defined as "Empty"
_MyType
is "Empty"
_MyType
_MyType
is ""
the template treats it as a Windows
type which explains why it is referencing these classes that aren't available.So why are we not getting the proper _MyType
?
projectFileInfo.CommandLineArgs
loaded from the ProjectFile
in MSBuildProjectLoader.Worker
shows many defined symbols but some odd character escaping.RpcClient
, the define looks like "/define:\"CONFIG=/\"Debug/\",DEBUG=-1,TRACE=-1,PLATFORM=/\"AnyCPU/\",NET=-1,NET9_0=-1,NETCOREAPP=-1,_MyType=/\"Empty/\",NET5_0_
_MyType=/\"Empty/\"
CommandLineArgs
come from reading the VbcCommandLineArgs
Item from the design time build.VbcCommandLineArgs
Item from a design-time build binlog, _MyList
is report /"Empty/"
Vbc
task's CommandLineArguments and I see the quotes properly escaped.
'\'
with '/'
) when creating the VbcCommandLineArgs
TaskItem./"Empty/"
into /\"Empty/\"
when escaping the double quotes.MSBuildProjectLoader.Worker
and inspecting the parsed commandLineArgs.Errors
there is indeed an error that is not surfaced.
error BC31030: Conditional compilation constant 'CONFIG= ^^ ^^ /"Debug/"' is not valid: Syntax error in conditional compilation expression.
Options:
*CommandLineArgs
Items as we already maintain *CommandLineArgumentReader
classes which read build Properties (importantly not Items) to gather the same information./"
in the CommandLineArgs ItemSpec as an escaped double quote. However, there might be false positives.cc: @jasonmalinowski & @rainersigwald for thoughts
Is that TaskItem constructor being called here?
Because if so, it looks like there's another constructor that doesn't do escaping:
Can we call that one instead?
Can we call that one instead?
Unfortunately it does call the other constructor which does the escaping. https://github.com/dotnet/msbuild/blob/4c6a5a963ceb38f77af4e57d28669872b616a8dc/src/Utilities/TaskItem.cs#L100
We could create out own ITaskItem implementation to wrap the args and pass it to this constructor. https://github.com/dotnet/msbuild/blob/4c6a5a963ceb38f77af4e57d28669872b616a8dc/src/Utilities/TaskItem.cs#L120-L123
Also, thank you for linking me to where this TaskItem was being created on our end.
@rainersigwald Any thoughts here? Invoking that copy constructor seems like a possible workaround.
. . . how on Earth is this the first time that unconditional correction has come up? We should definitely have an API to avoid it. (edit: https://github.com/dotnet/msbuild/issues/11083)
I think you're right that the best workaround is a custom ITaskItem--I don't think you'll need to create a TaskItem
from it though, you should be able to return your type IIRC.
Version Used: 4.10 Preview 1
Reported in https://github.com/dotnet/roslyn/pull/69225
Steps to Reproduce:
Expected Behavior: Project loads without any workspace diagnostics and compilation reports no compiler diagnostics.
Actual Behavior: Compilation reports "BC30002": Type 'Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase' is not defined.