ADO Pipeline fails with 'The "WriteProjectInfoFile" task failed unexpectedly.'

  • ALM used - Azure DevOps
  • CI system used - Azure DevOps
  • Commands used (extension changed so I can upload here): azure-pipelines.txt (1.9 KB)
  • Languages of the repository: C#, JS
  • Error observed:

Build pipeline using yaml completes successfully but fails when I add the Sonar tasks. Relevant error message below:

Using "WriteProjectInfoFile" task from assembly "D:\a\1\.sonarqube\bin\SonarScanner.MSBuild.Tasks.dll".
Task "WriteProjectInfoFile" (TaskId:125)
  Task Parameter:
      AnalysisResults=
          D:\a\1\.sonarqube\conf\0\FilesToAnalyze.txt
                  Id=FilesToAnalyze (TaskId:125)
  Task Parameter:Configuration=Release (TaskId:125)
  Task Parameter:IsTest=False (TaskId:125)
  Task Parameter:
      AnalysisSettings=
          sonar.cs.roslyn.reportFilePaths
                  Value=D:\a\1\.sonarqube\out\0\Issues.json
          sonar.cs.analyzer.projectOutPaths
                  Value=D:\a\1\.sonarqube\out\0 (TaskId:125)
  Task Parameter:SolutionConfigurationContents=<SolutionConfiguration>
    <ProjectConfiguration Project="{DDF717E3-AC63-40DE-B21D-FFACE761894C}" AbsolutePath="D:\a\1\s\src\https://dnndev.me:44305" BuildProjectInSolution="False">Debug|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{AFAEBFDD-1A7F-4B62-9D29-DB0CFAE0A7B5}" AbsolutePath="D:\a\1\s\src\Modules\CollegeDataService\CollegeDataService.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{47E428AD-B105-4437-A2B8-5568929D503D}" AbsolutePath="D:\a\1\s\src\Modules\CollegeSkin\CollegeSkin.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{8AE9375A-E112-46EC-B7DC-2CD63BBA7B08}" AbsolutePath="D:\a\1\s\src\Modules\ResidentialApplicantManager\ResidentialApplicantManager.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{7D61A32C-0F21-453F-A981-BD8E5A3A5304}" AbsolutePath="D:\a\1\s\src\Modules\ResidentialAdministration\ResidentialAdministration.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{4130D773-4930-4C21-9BCF-0C5244F585D0}" AbsolutePath="D:\a\1\s\src\Modules\ResidentialApplicantDetail\ResidentialApplicantDetail.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{E1D07E4C-DF07-4010-AFF0-8CDD708ED085}" AbsolutePath="D:\a\1\s\src\Common\Common.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
    <ProjectConfiguration Project="{5007F46C-660C-4600-B6F7-29710ACF51EA}" AbsolutePath="D:\a\1\s\test\Common.Test\Common.Test.csproj" BuildProjectInSolution="True">Release|AnyCPU</ProjectConfiguration>
  </SolutionConfiguration> (TaskId:125)
  Task Parameter:TargetFramework=netstandard2.0 (TaskId:125)
  Task Parameter:OutputFolder=D:\a\1\.sonarqube\out\0 (TaskId:125)
  Task Parameter:ProjectName=Common (TaskId:125)
  Task Parameter:Platform=AnyCPU (TaskId:125)
  Task Parameter:ProjectLanguage=C# (TaskId:125)
  Task Parameter:FullProjectPath=D:\a\1\s\src\Common\Common.csproj (TaskId:125)
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018: The "WriteProjectInfoFile" task failed unexpectedly. [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018: System.NotSupportedException: The given path's format is not supported. [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.IO.FileInfo.Init(String fileName, Boolean checkHost) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.IO.FileInfo..ctor(String fileName) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at SonarScanner.MSBuild.Tasks.WriteProjectInfoFile.<GetProjectGuid>g__ArePathEquals|71_0(String filePath, FileInfo file) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at SonarScanner.MSBuild.Tasks.WriteProjectInfoFile.<>c__DisplayClass71_0.<GetProjectGuid>b__1(XElement element) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at SonarScanner.MSBuild.Tasks.WriteProjectInfoFile.GetProjectGuid() [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at SonarScanner.MSBuild.Tasks.WriteProjectInfoFile.Execute() [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\a\1\s\src\Common\Common.csproj]
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(370,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [D:\a\1\s\src\Common\Common.csproj]
Done executing task "WriteProjectInfoFile" -- FAILED. (TaskId:125)
Done building target "SonarWriteProjectData" in project "Common.csproj" -- FAILED.: (TargetId:152)
Done executing task "CallTarget" -- FAILED. (TaskId:123)
Done building target "InvokeSonarWriteProjectData_NonRazorProject" in project "Common.csproj" -- FAILED.: (TargetId:151)
Done Building Project "D:\a\1\s\src\Common\Common.csproj" (default targets) -- FAILED.
Project "D:\a\1\s\src\College.sln" (1) is building "D:\a\1\s\src\Common\Common.csproj" (3:3) on node 1 (default targets).
Building with tools version "Current".
Target "Build" skipped. Previously built successfully.
Done Building Project "D:\a\1\s\src\Common\Common.csproj" (default targets) -- FAILED.
Done executing task "MSBuild" -- FAILED. (TaskId:24)
Done building target "ResolveProjectReferences" in project "CollegeDataService.csproj" -- FAILED.: (TargetId:41)
  • Steps to reproduce - Build without Sonar tasks- success. Build with Sonar tasks - Consistently fails with error above
  • Potential workaround - none that I’ve found

I’ve been able to start analyzing one of our projects but this one fails. Anyone have any ideas?

Hello @wfincher
thanks for this report.
Many .Net experts have taken some days off this week, so I’ll try to help with an initial answer.
Two things I’ve spotted from your inputs:

  • you are using a rather old (and non supported) VS 2019 16.0 version. In particular it does not benefit from this fix. Can you bring your build and analysis to an up-to-date version (e.g. 16.9) and let us know of the outcome?
  • A rather strange absolute path is listed in your logs: D:\a\1\s\src\https://dnndev.me:44305 Even if this item is not marked for build, there may be something wrong with the .sln file there.

I have other repos/builds that are completing without issue using the same build version and similar project setup. However, I tried updating my pipeline to use the following and I still receive the same error:

    vmImage: windows-latest
...
- task: VSBuild@1
    displayName: Build Solution
    inputs:
      solution: '**/College.sln'
      platform: '$(BuildPlatform)'
      configuration: '$(BuildConfiguration)'

As for the path you note, that’s in reference to an IIS Express virtual directory and appears to be unrelated to this issue.

Of further note, the project failing “Common”, is a .Net Standard project defined as:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputPath>..\DNN-Website\bin</OutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.10.0" />
    <PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0" />
    <PackageReference Include="Refit" Version="3.0.1" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="DotNetNuke">
      <HintPath>..\DNN-Website\bin\DotNetNuke.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

However there are no oddly named files or paths, so this error message doesn’t make sense to me “The given path’s format is not supported.”

Hello @wfincher

Could you please provide as the verbose level logs? To acquire the verbose level logs you can do the following things:

  • please give us the verbose output of the scanner commands (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of the BEGIN and END steps)
  • please give the output of running MSBuild in verbose mode (/v:d)

I have attached the full logs as downloaded from Azure DevOps with system.debug and “Enable System Diagnostics” equal to “true”. The pertinent files will be:

  • “Agent job 1\6_SonarCloudPrepare.txt”
  • “Agent job 1\8_Build Solution.txt”

logs_126.zip (379.9 KB)

@wfincher

The analysis is failing because the AbsolutPath project “{DDF717E3-AC63-40DE-B21D-FFACE761894C}” in the solution is “D:\a\1\s\src\https://dnndev.me:44305”, which cannot be resolved as a valid path. We will investigate further how we can prevent the failure in this case.
Could you please give us some more information on that project, so we can understand why does it have such an AbsolutePath? What kind of project is it or how do you reference it?

@Caba_Sagi

To provide some context, our site runs on the DNN framework. Our solutions have a local IIS Express website that runs the main CMS website code (“DNN-Website” in the below image, and hosted locally at https://dnndev.me:44305 in a local path within our repo). Our custom code runs as modules (Web Application Projects) under virtual directories in DNN. We have modified our applicationhost.config to point these virtual directories to the code so Visual Studio knows how to execute/debug them.

The reference to the path https://dnndev.me:44305 is a reference via IIS Express. That path is configured to not build.

See below image for a better idea of what I mean. Here is how our modules are exposed to the main CMS via a virtual directory:

This all seems very strange. We have two other projects in SonarCloud that are setup the same way and they do not experience this issue. I am not seeing a difference in the way the solutions are configured that might lead to this. Besides, the error is shown from our Common.csproj - a Net Standard 2.0 class library. This project does not reference the DNN-Website project at all.

Hello @wfincher

I managed to create a reproducer and opened an issue for it, there you can track the progress for it.

You also mentioned that you have two other projects set up the same way and they are not failing, that is most possibly because they don’t have any project targeting .NET Framework or .NET Core 2.0, as the issue is only reproduced if you have that case.

1 Like

Thank you for continuing to look at this and opening a ticket @Caba_Sagi!

There may be something more to the issue though. Both my other projects that are setup the same way: they target .NET Framework 4.8 and reference the website in IIS Express. They analyze correctly in SonarCloud. Here’s an excerpt from one of those solution files:

Project(“{E24C65DC-7377-472B-9ABA-BC803B73C61A}”) = “WinshapeCamps-DNN”, “https://dnndev.me:44301”, “{A6C72F25-16DC-4978-A694-6E56A7121AA4}”
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = “true”
TargetFrameworkMoniker = “.NETFramework,Version%3Dv4.8”
ProjectReferences = “{6D3487B7-4C61-4CC8-8151-A6545B1299D3}|WinShapeData.dll;{73CC63A2-67D7-41A5-9FF3-80E38DAEEF07}|WinShapeHelper.dll;{E330297E-ECF5-45CE-9CC5-EF621F9780EF}|MailChimpAPI.dll;{B00C3A7C-EBCB-4777-9AD3-68F14611F192}|MandrillAPI.dll;{3CBF24A2-8EE5-4403-8DC2-C0A85A3995B8}|WinShapeShared.dll;{DA99A1F9-4BD4-4A32-8EB2-28E48D17E738}|CampDocsAPI.dll;{F3020F06-6B7B-4401-AEED-CB4944A29400}|WinShapeONCGlobalData.dll;{472C3DB9-04F1-430C-88F5-95F9D4197C58}|SharedComponents.dll;{5E802895-9165-4309-BCD7-F7D1905D8F52}|WinShapeCampsGlobalModule.dll;{74F62C2B-B935-4284-85DE-DF37F62A431C}|MailChimp.Net.V3.dll;{0F4725F2-A04C-4C1A-962E-A12712B76385}|EZTextingAPI.dll;{CFAF7C8E-D4F0-4394-9FC6-683FD3B64E49}|TwilioAPI.dll;{2B91A993-64A0-42DA-96C0-387A0D90BCB9}|Twilio.dll;{6FFABD7F-F137-465F-8CD1-141EB002F5EE}|WinShapeCommon.dll;”
Debug.AspNetCompiler.VirtualPath = “/dnndev.me_44301”
Debug.AspNetCompiler.PhysicalPath = "…..\Website"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\dnndev.me_44301"
Debug.AspNetCompiler.Updateable = “true”
Debug.AspNetCompiler.ForceOverwrite = “true”
Debug.AspNetCompiler.FixedNames = “false”
Debug.AspNetCompiler.Debug = “True”
Release.AspNetCompiler.VirtualPath = “/dnndev.me_44301”
Release.AspNetCompiler.PhysicalPath = "…..\Website"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\dnndev.me_44301"
Release.AspNetCompiler.Updateable = “true”
Release.AspNetCompiler.ForceOverwrite = “true”
Release.AspNetCompiler.FixedNames = “false”
Release.AspNetCompiler.Debug = “False”
SlnRelativePath = "…..\Website"
EndProjectSection
EndProject

I can reproduce the issue with .NET Framework 4.8 too, and in the same time you are right, there is more to this issue than just the IIS Express website reference and another project targeting .NET Core 2.0 or .NET Framework.
The order of projects inside the SolutionConfiguration also plays a role. The referenced website has to be in front of the other project targeting .NET Core 2.0 or .NET Framework in order to fail. We will fix the issue for the upcoming release of the scanner anyway so this does not happen in the future. Meanwhile you can try to remove the website reference from the solution and add it again, in theory that should move the ProjectConfiguration for it from the first place to the last place in the SolutionConfiguration and that way make the build failure disappear.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.