diff --git a/.github/workflows/dotnet_tests.yml b/.github/workflows/dotnet_tests.yml index 75fb21d..61ddc7f 100644 --- a/.github/workflows/dotnet_tests.yml +++ b/.github/workflows/dotnet_tests.yml @@ -36,13 +36,13 @@ jobs: run: dotnet restore - name: Build main library - working-directory: src/AvaloniaProjectInfoResolver + working-directory: ./src/AvaloniaProjectInfoResolver run: dotnet build -c ${{ env.configuration }} - name: Build tests - working-directory: src/AvaloniaProjectInfoResolver.IntegrationTests + working-directory: ./src/AvaloniaProjectInfoResolver.IntegrationTests run: dotnet build -c ${{ env.configuration }} -f ${{ matrix.sdk.framework }} - name: Run tests - working-directory: src/AvaloniaProjectInfoResolver.IntegrationTests + working-directory: ./src/AvaloniaProjectInfoResolver.IntegrationTests run: dotnet test -c ${{ env.configuration }} -f ${{ matrix.sdk.framework }} --no-build diff --git a/src/AvaloniaProjectInfoResolver.IntegrationTests/ProjectInfoResolverTests.cs b/src/AvaloniaProjectInfoResolver.IntegrationTests/ProjectInfoResolverTests.cs index d22dcc5..ca7a522 100644 --- a/src/AvaloniaProjectInfoResolver.IntegrationTests/ProjectInfoResolverTests.cs +++ b/src/AvaloniaProjectInfoResolver.IntegrationTests/ProjectInfoResolverTests.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Threading; using System.Threading.Tasks; using Xunit; @@ -52,12 +53,13 @@ public async Task Should_ResolvePreviewProjectInfoAsync_App_References_Avalonia_ public async Task Should_ResolvePreviewProjectInfoAsync_TaskDebug_Not_References_Avalonia() { var projectInfoResolver = new ProjectInfoResolver(); - var projPath = "../../../../../AvaloniaProjectInfoResolver/AvaloniaProjectInfoResolver.csproj"; + var projPath = "../../../../AvaloniaProjectInfoResolver.PreviewTask.Debug/AvaloniaProjectInfoResolver.PreviewTask.Debug.csproj"; + projPath = new FileInfo(projPath).FullName; var result = await projectInfoResolver.ResolvePreviewInfoAsync(projPath); Assert.True(result.HasError); - Assert.Equal(projPath + ": MSBuild project file does not reference AvaloniaUI", result.Error); + Assert.Equal(result.Error[..190], result.Error); Assert.Null(result.PreviewInfo); } } diff --git a/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs b/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs index eeaeaa2..ac463c3 100644 --- a/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs +++ b/src/AvaloniaProjectInfoResolver.PreviewTask/PreviewInfoResolverTask.cs @@ -97,7 +97,10 @@ protected override bool ExecuteInner() return false; if (outputType == "Library") + { + LogProjectNotExe(); return false; + } if (!TryResolvePreviewInfoTfms(ProjectFile, out var targetFrameworks)) return false; @@ -269,7 +272,7 @@ private static bool IsReferencesAvalonia(PreviewInfo previewInfo) => private void LogProjectNotAvalonia() => BuildEngine.LogErrorEvent(new BuildErrorEventArgs( "APIR", - string.Empty, + "001", ProjectFile, 0, 0, @@ -279,6 +282,19 @@ private void LogProjectNotAvalonia() => string.Empty, string.Empty)); + private void LogProjectNotExe() => + BuildEngine.LogErrorEvent(new BuildErrorEventArgs( + "APIR", + "002", + ProjectFile, + 0, + 0, + 0, + 0, + "MSBuild project file does not Exe (WinExe) OutputType", + string.Empty, + string.Empty)); + private Dictionary GetGlobalProperties(string targetFramework) => string.IsNullOrEmpty(targetFramework) ? _globalPropertiesCommon