dotnet / dotnet/project-system

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

Open
#9,022 1 comment 0 reactions 0 assignees View on GitHub
Area-VisualBasic Feature-Project-Properties-Designer Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

_This issue has a corresponding [ticket on Developer Community](https://developercommunity.visualstudio.com/t/Build-Events-setting-does-not-create-cor/1636738). 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](https://aka.ms/dc/file?name=B12e6acc8850c44e3885ae86133a656b9637776653499604446_project-properties.png&tid=12e6acc8850c44e3885ae86133a656b9637776653499604446))
- 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](https://aka.ms/dc/image?name=Bbda1244e28d44412b687b6a54389ecfe637776655246322716_project-files.png&tid=bda1244e28d44412b687b6a54389ecfe637776655246322716))
- C#: Target-Attribute was created
- VB: PreBuildEvent-Attribute was created

As statet in the [documentation](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview#build-events) 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.