From a8c7e1ad725792b9decfa7c9a1c456c91540e9b6 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 24 Mar 2017 09:49:16 +0100 Subject: [PATCH] Fix ITs on VS2017 slaves --- cix.sh | 4 ++-- .../com/sonar/it/scanner/msbuild/TestUtils.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cix.sh b/cix.sh index 7384939c5..f9c5eb114 100644 --- a/cix.sh +++ b/cix.sh @@ -7,7 +7,7 @@ set -x get_version() { if [ "DEV" == "$1" ]; then local assemblyInfoFile=../AssemblyInfo.Shared.cs - local version=`sed -bn "s|\[assembly: AssemblyVersion(\"\([0-9.]*\)\")\]|\1|p" $assemblyInfoFile | sed 's/\r//'` + local version=`sed -n "s|\[assembly: AssemblyVersion(\"\([0-9.]*\)\")\]|\1|p" $assemblyInfoFile | sed 's/\r//'` if [ -z $version ]; then echo "Failed to find assembly version in $assemblyInfoFile" @@ -33,4 +33,4 @@ get_version $SCANNER_PAYLOAD_VERSION SCANNER_PAYLOAD_VERSION=$output # default versions of csharp and vbnet plugin are defined in the pom file -mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -DfxcopVersion=LATEST_RELEASE +mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -DfxcopVersion=LATEST_RELEASE -Dmsbuild.path=$MSBUILD_PATH diff --git a/its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java b/its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java index 599320737..42099dbcc 100644 --- a/its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java +++ b/its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java @@ -44,9 +44,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.annotation.CheckForNull; - import org.apache.commons.io.FileUtils; import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; @@ -55,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestUtils { - public static final String MSBUILD_HOME = "msbuild.home"; + public static final String MSBUILD_PATH = "msbuild.path"; private final static Logger LOG = LoggerFactory.getLogger(ScannerMSBuildTest.class); public static Path prepareCSharpPlugin(TemporaryFolder temp) { @@ -73,7 +71,7 @@ public static Path prepareCSharpPlugin(TemporaryFolder temp) { if (locators.copyToFile(csharp, modifiedCs.toFile()) == null) { throw new IllegalStateException("Couldn't locate csharp plugin in the local maven repository: " + csharp); } - + String scannerPayloadVersion = getScannerPayloadVersion(); Path scannerImpl; @@ -164,13 +162,13 @@ public static Path projectDir(TemporaryFolder temp, String projectName) throws I } public static void runMSBuild(Orchestrator orch, Path projectDir, String... arguments) { - String msBuildHome = orch.getConfiguration().getString(MSBUILD_HOME, "C:\\Program Files (x86)\\MSBuild\\14.0"); - Path msBuildPath = Paths.get(msBuildHome).toAbsolutePath(); + String msBuildPathStr = orch.getConfiguration().getString(MSBUILD_PATH, "C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\MSBuild.exe"); + Path msBuildPath = Paths.get(msBuildPathStr).toAbsolutePath(); if (!Files.exists(msBuildPath)) { - throw new IllegalStateException("Unable to find MSBuild at " + msBuildPath.toString() + ". Please configure property '" + MSBUILD_HOME + "'"); + throw new IllegalStateException("Unable to find MSBuild at " + msBuildPath.toString() + ". Please configure property '" + MSBUILD_PATH + "'"); } - int r = CommandExecutor.create().execute(Command.create(msBuildPath.resolve("bin/MSBuild.exe").toString()) + int r = CommandExecutor.create().execute(Command.create(msBuildPath.toString()) .addArguments(arguments) .setDirectory(projectDir.toFile()), 60 * 1000); assertThat(r).isEqualTo(0);