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

Build fails with the update as of Mar 8th commit in main #614

Closed
npagare opened this issue Mar 9, 2021 · 5 comments · Fixed by #632
Closed

Build fails with the update as of Mar 8th commit in main #614

npagare opened this issue Mar 9, 2021 · 5 comments · Fixed by #632
Assignees
Labels
Bug Bug bug bug. Build Build related

Comments

@npagare
Copy link

npagare commented Mar 9, 2021

Describe the bug
local build of the OSS repo is failing with the following errors -
image

Severity Code Description Project File Line Suppression State Detail Description
Error CA1802 Field 'DicomServerBlobConfigurationSectionName' is declared as 'readonly' but is initialized with a constant value. Mark this field as 'const' instead. Microsoft.Health.Dicom.Blob {local path|\dicom-server\src\Microsoft.Health.Dicom.Blob\Registration\DicomServerBuilderBlobRegistrationExtensions.cs 23 Active A field is declared static and read-only (Shared and ReadOnly in Visual Basic), and is initialized by using a value that is computable at compile time. Because the value that is assigned to the targeted field is computable at compile time, change the declaration to a const (Const in Visual Basic) field so that the value is computed at compile time instead of at run?time.

image

Your help will be appreciated. Thank you.

To Reproduce
Steps to reproduce the behavior:

  1. Update the repo the commit point - bd33cf2 - Refactor Project Files (Refactor Project Files #606)
  2. Build the solution using VS 16.9.0
  3. Observer all the errors as outlined in the first screenshot

Expected behavior
Solution Build resulting in no errors

Actual behavior
See the attached screenshot above.

@npagare
Copy link
Author

npagare commented Mar 9, 2021

Same error with today's commit : be2a547 - Bump NSubstitute from 4.2.1 to 4.2.2 in /converter/dicom-cast (#624)

Is this to do with c# version ?

@wsugarman
Copy link
Member

I was able to mostly root cause the issue.

The problem lies in the difference between the .NET SDK in the global.json (5.0103) and the .NET SDK used by the latest Visual Studio (5.0.201). I can build the solution without issue from the command line using dotnet build, as can our pipelines. That is because they are using a version of the .NET SDK from the global.json file. However, once I tried updating the SDK, I immediately saw the same errors we both see in Visual Studio. It must mean that the Intellisense is using a newer version of the .NET SDK.

Specifically, it appears the analyzer has gotten cleverer at detecting CA1802 around interpolated strings.

So to fix this issue, I'll put out a PR to fix the VS warnings, and I'll attempt to pin the analyzer warnings to version 5 of the SDK. However, given that VS may use the latest version of the SDK for intellisense, it may not prevent future tooling breaks. I'll investigate what can be done about the intellisense. I can't imagine we're alone in this.

@npagare
Copy link
Author

npagare commented Mar 10, 2021

Hi @wsugarman , I am not sure if that's going to resolve the issue for good.
I was getting the same error even after installing the .Net SDK 5.0.103 to match entry in the global.json.
Is there a setting that needs to set up to route the sdk for build based on certain configuration in the solution / project to override VS settings ?

@wsugarman
Copy link
Member

wsugarman commented Mar 10, 2021

The problem isn't because of your .NET SDK version; it is because the one used by Visual Studio for its static code analyzers in the latest version (presumably starting at v16.9). I am bumping the version of the SDK we use to the latest Visual Studio one, but this behavior seems incorrect. I will follow up with the Visual Studio team to see if it's intended that their analyzers use their own .NET SDK version instead of the one specified in the global.json.

Does the issue go away if you try to build from the command line the top-level directory? This should use 5.0.103 and can be confirmed with dotnet --version in the directory:

pushd <dicom-server repository>
dotnet --version
dotnet build Microsoft.Health.Dicom.sln

@wsugarman
Copy link
Member

I have opened up a separate issue with Visual Studio here.

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

Successfully merging a pull request may close this issue.

2 participants