From 31914e321ca0de4eb14fcfa7dab10282919db4dd Mon Sep 17 00:00:00 2001 From: Ng Yuk Man Date: Mon, 18 Mar 2019 11:23:55 +0800 Subject: [PATCH] Fix regression Change-Id: I0f370706ccbb54e69b526c585ba6e431b59b86f8 --- CHANGELOG.md | 2 ++ .../com/ullink/AssemblyInfoVersionPatcher.groovy | 14 +++++++------- src/main/groovy/com/ullink/Msbuild.groovy | 10 +++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83c2f50..d6f7de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ # 3.3 ### Fixed * Failed to resolve msbuild in MacOS #113 (thanks @kkalisz) +* Failed to run AssemblyInfoPatcher when attribute is not set or patching AssemblyInfo.cs +* Improve warnings log when project not found # 3.2 ### Added diff --git a/src/main/groovy/com/ullink/AssemblyInfoVersionPatcher.groovy b/src/main/groovy/com/ullink/AssemblyInfoVersionPatcher.groovy index 84b3312..3e2be36 100644 --- a/src/main/groovy/com/ullink/AssemblyInfoVersionPatcher.groovy +++ b/src/main/groovy/com/ullink/AssemblyInfoVersionPatcher.groovy @@ -28,7 +28,7 @@ class AssemblyInfoVersionPatcher extends DefaultTask { if (it.properties.UsingMicrosoftNETSdk == 'true') { it.properties.MSBuildProjectFullPath } else { - it?.getItems('Compile').find { Files.getNameWithoutExtension(it) == 'AssemblyInfo' } + it?.getItems('Compile').find { Files.getNameWithoutExtension(it.name) == 'AssemblyInfo' } } } })) @@ -63,22 +63,22 @@ class AssemblyInfoVersionPatcher extends DefaultTask { Property informationalVersion @Input - String title + String title = '' @Input - String company + String company = '' @Input - String product + String product = '' @Input - String copyright + String copyright = '' @Input - String trademark + String trademark = '' @Input - String assemblyDescription + String assemblyDescription = '' @Input def charset = 'UTF-8' diff --git a/src/main/groovy/com/ullink/Msbuild.groovy b/src/main/groovy/com/ullink/Msbuild.groovy index 48ecf55..3d27715 100644 --- a/src/main/groovy/com/ullink/Msbuild.groovy +++ b/src/main/groovy/com/ullink/Msbuild.groovy @@ -143,8 +143,9 @@ class Msbuild extends ConventionTask { boolean resolveProject() { if (projectParsed == null && parseProject) { + def rootProjectFile = getRootedProjectFile() if (isSolutionBuild()) { - def result = parseProjectFile(getRootedSolutionFile()) + def result = parseProjectFile(rootProjectFile) allProjects = result.collectEntries { [it.key, new ProjectFileParser(msbuild: this, eval: it.value)] } def projectName = getProjectName() if (projectName == null || projectName.isEmpty()) { @@ -157,12 +158,15 @@ class Msbuild extends ConventionTask { } } } else if (isProjectBuild()) { - def result = parseProjectFile(getRootedProjectFile()) + def result = parseProjectFile(rootProjectFile) allProjects = result.collectEntries {[it.key, new ProjectFileParser(msbuild: this, eval: it.value)]} projectParsed = allProjects.values().first() + if (!projectParsed) { + logger.warn "Parsed project ${rootProjectFile} is null (not a solution / project build)" + } } } - logger.warn "Parsed project is null (not a solution / project build)" + projectParsed != null }