Skip to content

Platform configuration is applied to other builds in batch scripts #10915

@dn9090

Description

@dn9090

Issue Description

I'm not sure if it's a bug, intentional or if I forgot something - but the behavior of msbuild / dotnet build within batch scripts doesn't make sense to me.
I have a “release” batch script in which another batch script is called that builds a CPP project using msbuild. Then the “release” script simply uses dotnet build -c Release to first create a release build of a .NET Standard project and then dotnet pack to create the Nuget package.
The following folder structure is generated:

bin/
  x64/
    Release/
      myproject.1.0.0.nupkg
      netstandard2.0/
        myproject.dll
        ...

If the lines of the “release” script are executed manually in the console step by step, the following folder structure is created (which is also the expected result):

bin/
  Release/
    myproject.1.0.0.nupkg
    netstandard.2.0/
      myproject.dll
      ...

It looks as if msbuild is applying the platform configuration of the CPP build to the dotnet release build in the batch script, although I have not specified the platform anywhere.

Steps to Reproduce

Here are my scripts:
release.bat

CALL build.bat Release
CALL dotnet build NETPROJECT -c Release
CALL dotnet pack NETPROJECT
CALL docfx .\docfx.json

build.bat

SET VcVarsPath=%VSPath%\VC\Auxiliary\Build\vcvarsall.bat
CALL "%VcVarsPath%" x64 > nul 2>&1
[...]
IF "%Debug%"=="1" SET Configuration=Debug
IF "%Release%"=="1" SET Configuration=Release

CALL msbuild %Project% /p:Configuration=%Configuration% /p:Platform=x64

I execute the lines of the release.bat manually on the console:

> build.bat Release
> dotnet build NETPROJECT -c Release
> dotnet pack NETPROJECT

Expected Behavior

I expect the batch script to generate the same result as if I execute the lines manually.
I have also tried to reset the configuration with dotnet restore / dotnet clean - without success.

Actual Behavior

For some reason, the platform configuration is applied in all subsequent dotnet calls if msbuild was previously executed with a platform configuration (in a batch file).

Analysis

No response

Versions & Configurations

17.3.1.41501

Metadata

Metadata

Assignees

Labels

closed-by-botClosed due to lack of activityneeds-more-infoIssues that need more info to continue investigation.staleFor issues that haven't had activity in some time.triaged

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions