-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform configuration is applied to other builds in batch scripts #10915
Comments
Thank you for the report. Please be aware that MSBuild is resolving properties values from environment variables (if the MSBuild script is dereferencing property, that is not explicitly defined while an env var with same name exists - it'll be used). This seems what is happening in your case - as you are defining env var with name |
Thank you for your answer. Is there a way to prevent this? I find the order somehow strange. If no parameters are passed - okay makes sense (even if I would have preferred to name the variables MS_BUILD_CONFIGURATION) - but with CLI parameters I expected nothing to be pulled in. |
Unfortunately this would break some of the common targets shipped with SDK/VS. |
As for the mentioned feature - from .NET 9.0 (or 17.12 if you use msbuild.exe) you can opt in to the 'BuildCheck' on commandline via The BC0103 is just suggestion level and scoped to user code - as this practice is still wide-spread. In order to increase to severity and scope of check You'd need to add an [*.csproj]
build_check.BC0103.severity=warning
build_check.BC0103.scope=all and then run your build with buildcheck opted in:
you'd then see something like:
Which gives you info about what all properties in your build are sourced from env |
@dn9090 I just wanted to check if there is anything further you think should be done on MSBuild side? |
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 thendotnet pack
to create the Nuget package.The following folder structure is generated:
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):
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
build.bat
I execute the lines of the release.bat manually on the console:
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
The text was updated successfully, but these errors were encountered: