Chathu.Thanthrige
Chathu.Thanthrige

Reputation: 133

Resolve the build waring The parameter to the compiler is invalid, '/define:$(BUILDCONFIGURATION)' will be ignored in NET 6.0

in my pipeline build .yml I have buildConfiguration: "Release" and use it in the build command

task: DotNetCoreCLI@2
            displayName: Build
            inputs:
              command: build
              projects: "**/*.csproj"
              arguments: '--configuration $(buildConfiguration)

I got

6.0.101\Roslyn\Microsoft.CSharp.Core.targets(75,5): Warning MSB3052: The parameter to the compiler is invalid, '/define:$(BUILDCONFIGURATION)' will be ignored.

in NET 6.0 build. Any suggestions for fix this warning?

Upvotes: 1

Views: 3435

Answers (2)

Chathu.Thanthrige
Chathu.Thanthrige

Reputation: 133

I resolved the above build issue by updating the pipelineenter image description here

Upvotes: 1

Leo Liu
Leo Liu

Reputation: 76910

Resolve the build waring The parameter to the compiler is invalid, '/define:$(BUILDCONFIGURATION)' will be ignored in NET 6.0

Since you could not share the whole YAML file, to resolve this issue requires you to do more troubleshooting.

As a suggestion, you can try changing your variable to a specific value to test if the issue persists, just instead of $(buildConfiguration) to release:

- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: build
    projects: Net6Test/Net6Test/Net6Test.csproj
    arguments: '--configuration release'

As test, I have created a .NET 6 sample project, and build it with below YAML scripts, and it works fine:

pool:
  name: xxxx

variables:
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: build
    projects: Net6Test/Net6Test/Net6Test.csproj
    arguments: '--configuration $(buildConfiguration)'

Upvotes: 1

Related Questions