Skip to content

Standard build variables are not replaced in before/after build scripts. #677

Open
@TheRealPiotrP

Description

@TheRealPiotrP

Moving from https://github.com/dotnet/cli/issues/5095 on behalf of @mdekrey


Sorry if this isn't the right spot; I wasn't sure if the MSBuild repo was a better location for this report or not. Simplest steps are below, but I originally accessed this via Visual Studio, which gave menus for the "macro" variables that did not get replaced. Note that this occurs for both project variables, not just solution variables, as the example uses the dotnet cli.

Steps to reproduce

  1. Create a new project (dotnet new)
  2. Modify your .csproj to have PreBuildEvent or PostBuildEvent that uses build variables as documented in previous C# projects. For example:
    <PropertyGroup Label="Configuration">
      <PreBuildEvent>echo $(OutDir)</PreBuildEvent>
      <PostBuildEvent>echo $(OutDir)</PostBuildEvent>
    </PropertyGroup>
  1. Restore packages. (dotnet restore)
  2. Build the project. (dotnet build)

Expected behavior

Standard build variables should be replaced in before/after build scripts.

Microsoft (R) Build Engine version 15.1.458.808
Copyright (C) Microsoft Corporation. All rights reserved.

  bin\Debug\netcoreapp1.0\
  test -> C:\Users\Me\Source\test\bin\Debug\netcoreapp1.0\test.dll
  bin\Debug\netcoreapp1.0\

Actual behavior

Standard build variables are not replaced in before/after build scripts.

Microsoft (R) Build Engine version 15.1.458.808
Copyright (C) Microsoft Corporation. All rights reserved.

  ECHO is on.
  test -> C:\Users\Me\Source\test\bin\Debug\netcoreapp1.0\test.dll
  ECHO is on.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview4-004233)

Product Information:
 Version:            1.0.0-preview4-004233
 Commit SHA-1 hash:  8cec61c6f7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview4-004233

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions