Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/SonarScanner.MSBuild.Tasks/ProjectConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class ProjectConfig
/// </summary>
public string TargetFramework { get; set; }

/// <summary>
/// The location of the project.assets.json file produced by a NuGet restore.
/// This file location corresponds to the MSBuild property 'ProjectAssetsFile'.
/// </summary>
public string ProjectAssetsFile { get; set; }

/// <summary>
/// Saves the project configuration to the specified file as XML.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
<SonarQubeSetting Include="sonar.$(SQLanguage).scanner.telemetry" Condition="Exists($(SonarProjectTelemetryFilePath))">
<Value>$(SonarProjectTelemetryFilePath)</Value>
</SonarQubeSetting>
<SonarQubeSetting Include="sonar.$(SQLanguage).analyzer.projectAssetsFile" Condition="Exists($(ProjectAssetsFile))">
<Value>$(ProjectAssetsFile)</Value>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the ProjectAssetsFile path available in the Java ProjectSensor.

</SonarQubeSetting>
</ItemGroup>

<!-- Record the list of files as an analysis result -->
Expand Down Expand Up @@ -617,7 +620,8 @@
FilesToAnalyzePath ="$(AnalysisFileList)"
OutPath="$(ProjectSpecificOutDir)"
IsTest="$(SonarQubeTestProject)"
TargetFramework="$(TargetFramework)">
TargetFramework="$(TargetFramework)"
ProjectAssetsFile="$(ProjectAssetsFile)">
<Output TaskParameter="ProjectConfigFilePath" PropertyName="SonarProjectConfigFilePath" />
</WriteProjectConfigFile>

Expand Down
15 changes: 8 additions & 7 deletions src/SonarScanner.MSBuild.Tasks/WriteProjectConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using SonarScanner.MSBuild.Common;

namespace SonarScanner.MSBuild.Tasks;

Expand Down Expand Up @@ -54,6 +52,8 @@ public class WriteProjectConfigFile : Task

public string TargetFramework { get; set; }

public string ProjectAssetsFile { get; set; }

#endregion Input properties

[Output]
Expand All @@ -66,12 +66,13 @@ public override bool Execute()
ProjectConfigFilePath = Path.Combine(ConfigDir, FileConstants.ProjectConfigFileName);
var config = new ProjectConfig
{
AnalysisConfigPath= AnalysisConfigPath,
ProjectPath= ProjectPath,
FilesToAnalyzePath= FilesToAnalyzePath,
OutPath= OutPath,
AnalysisConfigPath = AnalysisConfigPath,
ProjectPath = ProjectPath,
FilesToAnalyzePath = FilesToAnalyzePath,
OutPath = OutPath,
ProjectType = IsTest ? ProjectType.Test : ProjectType.Product,
TargetFramework = TargetFramework
TargetFramework = TargetFramework,
ProjectAssetsFile = ProjectAssetsFile,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the file path available in the Roslyn analyzer.

};
config.Save(ProjectConfigFilePath);
return true;
Expand Down
Loading