Skip to content
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

dotnet build parameters (-p) don't work when joined by semicolon (;) in dotnet 6.0.400 #27059

Closed
GSonofNun opened this issue Aug 9, 2022 · 11 comments · Fixed by #27086
Closed
Assignees
Labels
Milestone

Comments

@GSonofNun
Copy link

Describe the bug

Using multiple MSBuild parameters joined by a semicolon in a dotnet build command don't work anymore in dotnet 6.0.400.

To Reproduce

Executing the following command doesn't work anymore:

dotnet build -p:propertyA=valueA;propertyB=valueB

But changing it to this does:

dotnet build -p:propertyA=valueA -p:propertyB=valueB

In my case, the command:

dotnet build -p:Version=1.1.1.1;AdditionalConstants=Beta

resulted in the following error:

Error NETSDK1018: Invalid NuGet version string: '1.1.1.1;AdditionalConstants=Beta'.

Exceptions (if any)

N/A

Further technical details

  • Using dotnet version 6.0.400 (previously worked in version 6.0.302)
  • Command being executed as part of an Azure DevOps build pipeline
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Aug 9, 2022
@horihel
Copy link

horihel commented Aug 10, 2022

can confirm this too.
as a workaround i found out that comma (",") works as a separator, but semicolon (";") does not.

For us this breaks the "pack" task (and a few others) in Azure Devops Pipelines, as they use semicolon as a seperator (and we can't change that)

@ThomasTosik
Copy link

We have also this problem since updating to 6.0.400 with the dotnet build command. Workaround with using "," instead of ";" worked for us.

@moejoe
Copy link

moejoe commented Aug 10, 2022

We have the same error on our azure-devops pipelines.
We reverted to dotnet 6.0.302 for the time being as a workaround

@baronfel
Copy link
Member

This was likely introduced in #26204, which itself was fixing a regression.

We should extend the testing matrix for MSBuild property forwarding and cover this case, which is fairly unique among CLI arguments: MSBuild allows semicolon or comma-delimited lists of key/value pairs.

In the meantime there are a few workarounds if you want to remain on the latest 6.0.400 version:

  • use commas as your delimiter instead of semicolons in a single -p option
  • specify multiple -p options, each one containing a single key/value pair

@baronfel baronfel added Area-CLI and removed untriaged Request triage from a team member Area-NetSDK labels Aug 10, 2022
GermanCoding added a commit to GermanCoding/jellyfin that referenced this issue Aug 12, 2022
hgy59 pushed a commit to SynoCommunity/spksrc that referenced this issue Aug 14, 2022
* update jellyfin 10.8.3
* update dotnet-sdk-6.0 to v6.0.400
- update dotnet sdk and add fix for dotnet/sdk#27059
* Update spk/jellyfin/Makefile
Co-authored-by: Sebastian Schmidt <publicarray@users.noreply.github.com>
* adjust msbuild parameters
- avoid optimize (ReadyToRun assemblies)
- use original parameters to avoid debug files
* adjust unsupported archs for dotnet
Co-authored-by: hgy59 <hpgy59@gmail.com>
Co-authored-by: Sebastian Schmidt <publicarray@users.noreply.github.com>
@HolyPrapor
Copy link

We have also faced this problem, although in a slightly different way: it is now impossible to specify multiple values for a single property using ; delimeter.

In our projects, we use -p:TargetFrameworks=\"net5.0;net6.0\" which worked flawlessly, until that specific version of dotnet.

However, specifying <TargetFrameworks>net6.0;net5.0</TargetFrameworks> directly in csproj still works as intended.

@rolfbjarne
Copy link
Member

rolfbjarne commented Aug 18, 2022

I'm seeing the same problem as @HolyPrapor, with the RuntimeIdentifiers property.

Setting it on the command line like this:

dotnet build '/p:RuntimeIdentifiers="osx-arm64;osx-x64"'

doesn't work anymore, because it ends up being passed as a string (instead of an array of strings) to the RuntimeIdentifiers property of the ProcessFrameworkReferences task.

The difference seems to be that the property is now quoted when passed to msbuild:

--property:RuntimeIdentifiers=osx-arm64%3Bosx-x64

@X-Celcius
Copy link

X-Celcius commented Aug 22, 2022

I would like to emphasize that this causes build failures from one day to another in Azure Pipelines because of the way the DotNetCoreCLI task runs the dotnet command. In our case we run dotnet using arguments like these:

- task: DotNetCoreCLI@2
  inputs:
    command: pack
    configuration: $(buildConfiguration)
    packagesToPack: '**/*.csproj'
    buildProperties: 'InformationalVersion=Foo'

And it fails because under the hood dotnet will be run using this argument:

dotnet pack [...] /p:Configuration=Release;InformationalVersion=Foo

Which since 6.0.400 will lead to the build configuration actually being Release;InformationalVersion=Foo instead of Release.

As you can see we don't specify semicolons or commas anywhere and we don't have a way to specify multiple -p options on the command line. I can see that this may need to be fixed in Azure Pipelines instead but I suspect this combination to lead to build failures all over the place.

@justinswork
Copy link

@baronfel this is fixed in .NET SDK 6.0.401 https://dotnet.microsoft.com/en-us/download/dotnet/6.0

@baronfel baronfel added this to the 6.0.401 milestone Sep 13, 2022
@baronfel
Copy link
Member

baronfel commented Sep 13, 2022

Yep! This just wasn't closed when the linked PR merged. I'll do so now.

@henryzhao95
Copy link

I'm still seeing the same issue with 6.0.401.
When passing in:

dotnet pack foo.csproj --no-build --no-restore  -o C:\tmp -c Release /p:NuspecFile=foo.nuspec -p:NuspecProperties=\"Version=1.0.41566;configuration=Release;Id=Foo;Description=Foo\"

I receive the following error:
C:\Program Files\dotnet\sdk\6.0.401\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): error : An error occured while trying to parse the value '1.0.41566;configuration=Release;Id=Foo;Description=Foo' of property 'version' in the manifest file. [foo.csproj]
C:\Program Files\dotnet\sdk\6.0.401\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): error : '1.0.41566;configuration=Release;Id=Foo;Description=Foo' is not a valid version string. (Parameter 'value') [foo.csproj]

@justinswork
Copy link

@henryzhao95 the issue you're seeing might be related to #15482. Otherwise do you need to escape the quotes around your NuspecProperties? I would just try removing the backslashes

dotnet pack foo.csproj --no-build --no-restore -o C:\tmp -c Release /p:NuspecFile=foo.nuspec -p:NuspecProperties="Version=1.0.41566;configuration=Release;Id=Foo;Description=Foo"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants