project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Build Events setting does not create correct MSBuild property for the .NET SDK project

Open vsfeedback opened this issue 2 years ago • 1 comments

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:

  1. Create 2 projects from template.
    • Class Library (C# for .NET Standard or .NET Core)
    • Class Library (VB for .NET Standard or .NET Core)
  2. 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
  3. 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

vsfeedback avatar May 17 '23 21:05 vsfeedback

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:

B12e6acc8850c44e3885ae86133a656b9637776653499604446_project-properties

Bbda1244e28d44412b687b6a54389ecfe637776655246322716_project-files

drewnoakes avatar May 18 '23 11:05 drewnoakes