Skip to content

Commit 992e972

Browse files
committed
Enhance log message
1 parent 2c91c64 commit 992e972

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/Detector/DotNetCore/ProjectFileProviders/ExplicitProjectFileProvider.cs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Licensed under the MIT license.
44
// --------------------------------------------------------------------------------------------
55

6+
using System;
67
using System.IO;
78
using Microsoft.Extensions.Logging;
89
using Microsoft.Extensions.Options;
9-
using Microsoft.Oryx.BuildScriptGenerator;
1010

1111
namespace Microsoft.Oryx.Detector.DotNetCore
1212
{
@@ -18,7 +18,6 @@ internal class ExplicitProjectFileProvider : IProjectFileProvider
1818
{
1919
private readonly IOptions<DetectorOptions> options;
2020
private readonly ILogger<ExplicitProjectFileProvider> logger;
21-
private readonly BuildScriptGeneratorOptions commonOptions;
2221

2322
public ExplicitProjectFileProvider(
2423
IOptions<DetectorOptions> options,
@@ -44,33 +43,19 @@ public string GetRelativePathToProjectFile(DetectorContext context)
4443
if (context.SourceRepo.FileExists(projectFile))
4544
{
4645
this.logger.LogDebug($"Using the given .NET Core project file to build.");
46+
this.logger.LogInformation("Using the given .NET Core project file to build.");
4747
}
48-
else
48+
else
4949
{
50-
this.logger.LogWarning($"Could not find the .NET Core project file.");
51-
52-
// Check if .NET Core is the target platform before failing
53-
var userProvidedPlatformName = this.commonOptions.PlatformName;
54-
55-
// If platform is not dotnet, skip .NET Core requirements. Dotnet file detection will still happen.
56-
if (!string.IsNullOrEmpty(userProvidedPlatformName) &&
57-
!userProvidedPlatformName.Equals("dotnet", StringComparison.OrdinalIgnoreCase))
58-
{
59-
this.logger.LogDebug(
60-
$"Target platform is '{userProvidedPlatformName}', not 'dotnet'. " +
61-
"Skipping .NET Core project file requirement.");
62-
return null;
63-
}
64-
65-
// If platform is dotnet but PROJECT doesn't specify .csproj or .fsproj file
66-
if (userProvidedPlatformName.Equals("dotnet", StringComparison.OrdinalIgnoreCase) &&
67-
!IsValidDotNetProjectFile(projectFileWithRelativePath))
50+
if (!this.IsValidDotNetProjectFile(projectFileWithRelativePath))
6851
{
6952
this.logger.LogDebug("PROJECT variable doesn't specify a valid .NET project file (.csproj or .fsproj).");
7053
return null;
7154
}
7255

73-
throw new InvalidProjectFileException("Could not find the .NET Core project file.");
56+
throw new InvalidProjectFileException(
57+
$"Could not find the .NET Core project file specified in PROJECT environment variable: '{projectFileWithRelativePath}'. " +
58+
"Please ensure the file exists or update the PROJECT environment variable to point to a valid .csproj or .fsproj file.");
7459
}
7560

7661
return projectFileWithRelativePath;

0 commit comments

Comments
 (0)