Build Events setting does not create correct MSBuild property for the .NET SDK project
This issue has a corresponding ticket on Developer Community. Please vote and comment there to make sure your voice is heard.
[severity:It's more difficult to complete my work]
To reproduce:
- Create 2 projects from template.
- Class Library (C# for .NET Standard or .NET Core)
- Class Library (VB for .NET Standard or .NET Core)
- Configure Build Events in project properties for both projects. (project-properties.png)
- C#: Properties > Build > Output > Pre-build event
- VB: Properties > Compile > Build Events... > Pre-build event command line
- Inspect created Build Events in project file (.csproj / .vbproj) (project-files.png)
- C#: Target-Attribute was created
- VB: PreBuildEvent-Attribute was created
As statet in the documentation for .NET SDK project files:
The properties PreBuildEvent and PostBuildEvent are not recommended in SDK-style projects, because macros such as $(ProjectDir) aren't resolved. [...]
So, to use Build Event macros in VB, i have to configure Build Events in the project file manually. This can get really tiresome, as the command in the project file is XML encoded. I was expecting, to configure Build Events for VB directly in the IDE like it is for C#.
I´m on: Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.0.4
This ticket was filed in 17.0.4, before we migrated VB projects to the new Project Properties UI. We should investigate whether there is still an issue here.
EDIT this is still an issue.
Images from the ticket: