teamcity-dotnet-plugin icon indicating copy to clipboard operation
teamcity-dotnet-plugin copied to clipboard

Problem parsing .rsp with .NET SDK 6.0.301

Open rokleM opened this issue 2 years ago • 21 comments

When I try to start a build I get this:

dotnet restore Starting: .NET SDK 6.0.301 "C:\Program Files\dotnet\dotnet.exe" restore B:\BuildAgents\work\d1489dc070d6d243\MSBuildTasks.sln --source https://api.nuget.org/v3/index.json --source https://localhost:8111/httpAuth/app/nuget/feed/_Root/default/v2 @B:\BuildAgents\BuildAgent3\temp\agentTmp\1.rsp in directory: B:\BuildAgents\work\d1489dc070d6d243 MSBUILD : error MSB1006: Property is not valid. Switch: B:\BuildAgents\BuildAgent3\plugins\dotnet\tools\vstest15 For switch syntax, type "MSBuild -help" Process exited with code 1

This started happening once I updated BuildTools to 17.2.4, which includes said SDK.

rokleM avatar Jun 15 '22 20:06 rokleM

+1 on this, I've also just updated to latest version of .net 6 (6.0.301) and have started seeing this issue in Linux/Debian:

[21:28:18]E: Step 1/14: Publish (.NET)
[21:28:18]i:     [Step 1/14] dotnet --version
[21:28:18]i:     [Step 1/14] Starting:  Getting the .NET SDK version /usr/share/dotnet/ dotnet  --version
[21:28:18]i:     [Step 1/14] in directory:  /opt/teamcity-agent-1/work/eddc24f5d5a9ddc4
[21:28:18]i:     [Step 1/14] 6.0.301
[21:28:18]i:     [Step 1/14] Process exited with code 0
[21:28:18]E:     [Step 1/14] dotnet publish
[21:28:18] :         [dotnet publish] Starting:  [30;1m.NET SDK 6.0.301  [0m/usr/share/dotnet/dotnet publish /opt/teamcity-agent-1/work/eddc24f5d5a9ddc4/Src/XXXXX.sln --configuration Release --output output/ @/opt/teamcity-agent-1/temp/agentTmp/1.rsp -p:PackageVersion=1.0.1767 -p:OutputPath=output/ -p:PublishDir=output/
[21:28:18] :         [dotnet publish] in directory: /opt/teamcity-agent-1/work/eddc24f5d5a9ddc4
[21:28:18] :         [dotnet publish] Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
[21:28:18] :         [dotnet publish] Copyright (C) Microsoft Corporation. All rights reserved.
[21:28:18] :         [dotnet publish] 
[21:28:18] :         [dotnet publish] MSBUILD : error MSB1006: Property is not valid.
[21:28:18] :         [dotnet publish] Switch: /opt/teamcity-agent-1/plugins/dotnet/tools/vstest15
[21:28:18] :         [dotnet publish] 
[21:28:18] :         [dotnet publish] For switch syntax, type "MSBuild -help"
[21:28:18]W:         [dotnet publish] Process exited with code 1
[21:28:18]E:         [dotnet publish] Process exited with code 1 (Step: Publish (.NET))

When looking at /opt/teamcity-agent-1/temp/agentTmp/1.rsp I can see the following line:

-p:VSTestTestAdapterPath=".;/opt/teamcity-agent-1/plugins/dotnet/tools/vstest15"

When I modify it to the below:

-p:VSTestTestAdapterPath="/opt/teamcity-agent-1/plugins/dotnet/tools/vstest15"

And then run the same command via bash, it works ok, but next time I run a build on TeamCity the 1.rsp file re-generates and the same problem occurs.

alvaromarithompson avatar Jun 15 '22 20:06 alvaromarithompson

This seems to have been reported to the main dotnet sdk repo https://github.com/dotnet/sdk/issues/26026

alvaromarithompson avatar Jun 15 '22 21:06 alvaromarithompson

Related issue: https://youtrack.jetbrains.com/issue/TW-76527/Running-a-NET-builder-task-on-DotNet-6-SDK-solution-generates-a-build-error-MSBUILD-error-MSB1006-Property-is-not-valid

NikolayPianikov avatar Jun 16 '22 08:06 NikolayPianikov

Could you please uprade the .NET plugin for TeamCity 2022

NikolayPianikov avatar Jun 16 '22 08:06 NikolayPianikov

That's worked @NikolayPianikov - many thanks!

alvaromarithompson avatar Jun 16 '22 08:06 alvaromarithompson

Could you please uprade the .NET plugin for TeamCity 2022

Thanks, but even with this update the build fails when the build configuration name contains a comma.

-p:teamcity_buildConfName="Linux, DebugMode off"

error:

[dotnet build] MSBUILD : error MSB1006: Property is not valid. [dotnet build] Switch: DebugMode off)

loop-evgeny avatar Jun 16 '22 12:06 loop-evgeny

NikolayPianikov We use sentinelOne, and after installing the ".NET plugin" you mentioned, sentinelOne classifies it as ransomware due to its behaviour. Is this something you can comment on?

SRYER avatar Jun 22 '22 13:06 SRYER

@loop-evgeny please try this plugin

NikolayPianikov avatar Jun 22 '22 14:06 NikolayPianikov

@SRYER What program did this classification? .NET plugin doesn't have such feature

NikolayPianikov avatar Jun 22 '22 14:06 NikolayPianikov

@loop-evgeny please try this plugin

That works with a comma in the build configuration name, thanks! It's URL-encoded in the 1.rsp file now:

-p:teamcity_buildConfName="engine (Linux%2C DebugMode off)"

loop-evgeny avatar Jun 22 '22 15:06 loop-evgeny

@loop-evgeny please try this plugin

We are currently on TeamCity 2020.2.4. Would the above plugin work for it or could you post a version for TC 2020.2? Thanks.

akulich avatar Jun 23 '22 02:06 akulich

As a workaround, currently I add a global.json file in my solution to specify a particular .NET SDK version other than 6.0.301, then everything works again. The global.json file can be removed after this issue gets solved.

RickyLin avatar Jun 23 '22 03:06 RickyLin

A hint to the readers of this issue (which I missed first): the global.json does not need to be in the working/solution directory. You can also just place a global.json in your drive-root so that all builds on your server use this SDK version. This way we avoided updating all of our repositories and branches.

Danielku15 avatar Jun 23 '22 14:06 Danielku15

I've tried the new plugin but I'm having issues with multiple Nuget package sources. I tried to URL encode the semicolon separator but it looks like Team City parses the list and replaces my URL encoded semicolons with regular semicolons. Any workarounds for that or should I just force to SDK 6.0.300 instead?

schwede avatar Jun 23 '22 19:06 schwede

@schwede what command are you using?

NikolayPianikov avatar Jun 24 '22 11:06 NikolayPianikov

restore I tried to provide --source commands directly in the command line arguments to workaround it but I can't clear what's put in the package sources in the rsp file. There must be some kind of inherited behavior in my build because I get the same text in "-p:PackageSources" no matter what I put in "NuGet package sources".

schwede avatar Jun 24 '22 14:06 schwede

I'm getting the same issue with .NET restore, I pass in a Nuget.config file and get an error with the urls being passed as switches.

[dotnet restore] MSBUILD : error MSB1006: Property is not valid.
[dotnet restore] Switch: https://xxxxxxx/guestAuth/app/nuget/v1/FeedService.svc/

charliemckeegan avatar Jun 28 '22 08:06 charliemckeegan

@NikolayPianikov Can you explain how to install the plugin please?

Fabman08 avatar Jun 30 '22 11:06 Fabman08

@NikolayPianikov Can you explain how to install the plugin please?

Administration -> Plugins -> [Upload plugin zip]

Then restart server as prompted.

LionetChen avatar Jul 07 '22 07:07 LionetChen

same issue here. about to install TeamCity upgrade. I am hoping this does not cause further issues. All of our builds broke using 6.0.300

haldiggs avatar Aug 03 '22 16:08 haldiggs

It looks like the root cause in https://github.com/dotnet/sdk/issues/26026 is fixed as of .NET 6.0.303. I installed the latest version of .NET (6.0.400) and deleted my global.json workaround -- everything's working as expected now.

waf avatar Aug 11 '22 10:08 waf