Itiviti / gradle-msbuild-plugin

Gradle plugin for msbuild execution, supports C# project files for now
Apache License 2.0
101 stars 57 forks source link

MSBuild fails when intermediateDir is specified due to missing trailing slash #1

Closed gourleyman closed 11 years ago

gourleyman commented 11 years ago

I am getting this error when I try to specify the 'intermediateDir' for a 'msbuild' task:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(618,5): error : The IntermediateOutputPath must end with a trailing slash.

I was able to get a fix working locally. I can send a patch if you like, but essentially all that really needed to be done was add the slash. My patch has a few other small tweaks as well if you're interested.

gourleyman commented 11 years ago

Patch:

diff --git a/src/main/groovy/com/ullink/Msbuild.groovy b/src/main/groovy/com/ullink/Msbuild.groovy
index 5b294e2..d7686f6 100644
--- a/src/main/groovy/com/ullink/Msbuild.groovy
+++ b/src/main/groovy/com/ullink/Msbuild.groovy
@@ -173,10 +173,10 @@
         cmdParameters.DebugType = debugType
         cmdParameters.Optimize = optimize
         cmdParameters.DebugSymbols = debugSymbols
-        cmdParameters.OutputPath = destinationDir == null ? null : project.file(destinationDir)
-        cmdParameters.IntermediateOutputPath = intermediateDir == null ? null : project.file(intermediateDir)
         cmdParameters.Configuration = configuration
         cmdParameters.Platform = platform
+        cmdParameters.OutDir = destinationDir == null ? null : project.file(destinationDir).path + File.separator + configuration
+        cmdParameters.BaseIntermediateOutputPath = intermediateDir == null ? null : project.file(intermediateDir).path + File.separator
         if (defineConstants != null && !defineConstants.isEmpty()) {
             cmdParameters.DefineConstants = defineConstants.join(';')
         }
gluck commented 11 years ago

I can understand the (nasty) error about the trailing slash, but why did you have to switch from IntermediateOutputPath / OutputPath to BaseIntermediateOutputPath / OutDir ?

Wasn't the separator append enough to fix it ?

Thanks, and if you've got other fixes/improvements, feel free to share.

gourleyman commented 11 years ago

Yes the slash was enough. I saw somewhere that OutDir was recommended instead of OutputPath ... Not sure if the latter is deprecated or something, but no big deal if you don't want to include it.

As for the use of "base", I liked how it put my build artifacts in Debug or Release subdirectories.

In both cases you are right ... those changes aren't required so take them or leave them :-) On 2013-02-03 10:09 AM, "Francois Valdy" notifications@github.com wrote:

I can understand the (nasty) error about the trailing slash, but why did you have to switch from IntermediateOutputPath / OutputPath to _Base_IntermediateOutputPath / OutDir ?

Wasn't the separator append enough to fix it ?

Thanks, and if you've got other fixes/improvements, feel free to share.

— Reply to this email directly or view it on GitHubhttps://github.com/Ullink/gradle-msbuild-plugin/issues/1#issuecomment-13048160.

gluck commented 11 years ago

Fixed & released in 1.6. As per Microsoft.Common.targets content, the plugin makes sure some properties are always ending up with '\'. Also revised property handling as global properties are immutable.

Let me know if that works for you !