Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-11561

Auto removal of quotes from MSBuild options resulting in errors

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 5.8
    • 5.6.0
    • Windows
    • None

      During the specification of the build task we can specify something of the nature:

      /t:Release /p:BuildVersion="1.0.0.${bamboo.buildNumber}" /p:ProductsToRelease="JIRA;Bamboo;Fisheye"

      During execution of the task, Bamboo takes off the quotes around the property value which cause the build to fail because the semicolon in this case are used as property separator and hence the remaining part will be an invalid expression as reproetd in the microsoft KB article at http://msdn.microsoft.com/en-us/library/xx2ke5d2%28v=vs.80%29.aspx. Here is a sample of the build log:

      MSBUILD : error MSB1006: Property is not valid.
      

      If the quotes were not removed, all the three options will be considered as values of the property ProductsToRelease

            [BAM-11561] Auto removal of quotes from MSBuild options resulting in errors

            This workaround

            wrapper.java.additional.3=-Dbamboo.plugin.dotnet.msbuild.useResponseFile

            May work for MSBuild, but it doesn't work for MSDeploy at all. (We have it installed as a Command executable)

            Swift Capital added a comment - This workaround wrapper.java.additional.3=-Dbamboo.plugin.dotnet.msbuild.useResponseFile May work for MSBuild, but it doesn't work for MSDeploy at all. (We have it installed as a Command executable)

            We've just encountered the same issue that David mentioned (we use proj files too) after upgrading from 5.6.2 to 5.8.1. Any word on a fix for this?

            Chas Berndt added a comment - We've just encountered the same issue that David mentioned (we use proj files too) after upgrading from 5.6.2 to 5.8.1. Any word on a fix for this?

            I upgraded Bamboo to v5.8.0 from v5.3.3 on 17 March 2015. I have only just found that I have a number of builds that now fail with MSB1008: Only one project can be specified. Many of these builds have requirements rather more complex that simply building a .sln file so we use MSBuild targets files frequently. The circumstances described in this issue and in the comments implies that it is triggered when passing an MSBuild parameter with a space in it in the {{Options }} field of the job.
            What we have found is that the path to the Project File field of the job is also affected. If this field also contains a path, none of the directories in that path can contain a space.
            The only option for us was to rename any directories in any paths to targets files that contained spaces. This was unfortunate because there were many and all were under source control which meant wholesale copying, renaming and deleting of numerous paths.

            David FALLAS added a comment - I upgraded Bamboo to v5.8.0 from v5.3.3 on 17 March 2015. I have only just found that I have a number of builds that now fail with MSB1008: Only one project can be specified . Many of these builds have requirements rather more complex that simply building a .sln file so we use MSBuild targets files frequently. The circumstances described in this issue and in the comments implies that it is triggered when passing an MSBuild parameter with a space in it in the {{Options }} field of the job. What we have found is that the path to the Project File field of the job is also affected. If this field also contains a path, none of the directories in that path can contain a space. The only option for us was to rename any directories in any paths to targets files that contained spaces. This was unfortunate because there were many and all were under source control which meant wholesale copying, renaming and deleting of numerous paths.

            james.sweeney ATM it looks like Bamboo is trying to create response file in some special Windows directory and it might be not available to another process. Please make sure your remote agent on Windows has properly set java.io.tmpdir property (ie. you can configure it to agent-home/tmp directory). You can confgure this property using conf/wrapper.conf file in agent-home directory (search for wrapper.java.additional. option)

            Krystian Brazulewicz added a comment - james.sweeney ATM it looks like Bamboo is trying to create response file in some special Windows directory and it might be not available to another process. Please make sure your remote agent on Windows has properly set java.io.tmpdir property (ie. you can configure it to agent-home/tmp directory). You can confgure this property using conf/wrapper.conf file in agent-home directory (search for wrapper.java.additional. option)

            I'm stuck between a rock and a hard place on this one. Running 5.7.2, specifying bamboo.plugin.dotnet.msbuild.useResponseFile=true results in "MSBUILD : error MSB1022: Response file does not exist" while setting it false gives us the quoting error. We're only running .net on remote agents, so I've got no idea if this work on local agents, as the local machine is running CentOS. Time to file a support ticket i guess.

            James Sweeney added a comment - I'm stuck between a rock and a hard place on this one. Running 5.7.2, specifying bamboo.plugin.dotnet.msbuild.useResponseFile=true results in "MSBUILD : error MSB1022: Response file does not exist" while setting it false gives us the quoting error. We're only running .net on remote agents, so I've got no idea if this work on local agents, as the local machine is running CentOS. Time to file a support ticket i guess.

            @Esther Asenjo

            Is there a fix for this issue in 5.7.x at this time?

            Is there updated documentation you can point me to?

            Ryan Goodwin added a comment - @Esther Asenjo Is there a fix for this issue in 5.7.x at this time? Is there updated documentation you can point me to?

            sthr (Inactive) added a comment - - edited

            Hi markgillespie,

            Sorry to hear you are having issues with this task. There has been a significant amount of work on it, and a result of this we deal with the parameters in a different way in 5.7. We're working in updating the documentation to reflect this, covering pre 5.5, 5.6 and 5.7 itself. It will be available by next week. I will update this issue, and track down that this actually solves your problems.

            Sorry for any inconveniences again! We're working on fixing it.

            Cheers,
            Esther

            sthr (Inactive) added a comment - - edited Hi markgillespie , Sorry to hear you are having issues with this task. There has been a significant amount of work on it, and a result of this we deal with the parameters in a different way in 5.7. We're working in updating the documentation to reflect this, covering pre 5.5, 5.6 and 5.7 itself. It will be available by next week. I will update this issue, and track down that this actually solves your problems. Sorry for any inconveniences again! We're working on fixing it. Cheers, Esther

            Not working for us. I also wish Atlassian were consistent with their documentation. We use Windows Service, and I guess I am assuming correct, that I need to set this as such:

            tomcat7w.exe //ES//Bamboo

            Java tab,

            Mark Gillespie added a comment - Not working for us. I also wish Atlassian were consistent with their documentation. We use Windows Service, and I guess I am assuming correct, that I need to set this as such: tomcat7w.exe //ES//Bamboo Java tab,

            Krystian Brazulewicz added a comment - - edited

            To clear up the confusion
            MSBuild task in Bamboo 5.6.0 provides workaround for the argument parsing problems in form of optional use of msbuild's response file. In order to activate this workaround one needs to set
            bamboo.plugin.dotnet.msbuild.useResponseFile system property to true on all agents (and on Bamboo server if you use local agents).

            Remote agents.

            If you're starting agent manually you simply provide -Dbamboo.plugin.dotnet.msbuild.useResponseFile=true on the command line. If your agent is run as a service then make a change in the $BAMBOO_AGENT_HOME/conf/wrapper.conf configuration file:

            # The Bamboo Agent home configuration file
            wrapper.java.additional.1=-Dbamboo.home=/home/bamboo/bamboo-agent-home
            wrapper.java.additional.2=-Dbamboo.agent.ignoreServerCertName=false
            wrapper.java.additional.3=-Dbamboo.plugin.dotnet.msbuild.useResponseFile=true
            
            Bamboo server
            • stop Bamboo
            • add -Dbamboo.plugin.dotnet.msbuild.useResponseFile=true to JVM_REQUIRED_ARGS in $BAMBOO_INSTALL/bin/setenv.sh
            • start Bamboo

            Please leave a comment if that helped.

            Krystian Brazulewicz added a comment - - edited To clear up the confusion MSBuild task in Bamboo 5.6.0 provides workaround for the argument parsing problems in form of optional use of msbuild's response file. In order to activate this workaround one needs to set bamboo.plugin.dotnet.msbuild.useResponseFile system property to true on all agents (and on Bamboo server if you use local agents). Remote agents. If you're starting agent manually you simply provide -Dbamboo.plugin.dotnet.msbuild.useResponseFile=true on the command line. If your agent is run as a service then make a change in the $BAMBOO_AGENT_HOME/conf/wrapper.conf configuration file: # The Bamboo Agent home configuration file wrapper.java.additional.1=-Dbamboo.home=/home/bamboo/bamboo-agent-home wrapper.java.additional.2=-Dbamboo.agent.ignoreServerCertName=false wrapper.java.additional.3=-Dbamboo.plugin.dotnet.msbuild.useResponseFile=true Bamboo server stop Bamboo add -Dbamboo.plugin.dotnet.msbuild.useResponseFile=true to JVM_REQUIRED_ARGS in $BAMBOO_INSTALL/bin/setenv.sh start Bamboo Please leave a comment if that helped.

            It still doesn't work for me.
            I'm running Bamboo OnDemand 5.6 (Version: 5.6-OD-01-0070; Build number: 4409).

            My MSBuild task config is:

            Executable:
            MSBuild v4.0 (32bit)
            Project File:
            ERP.sln
            Options:
            /p:Configuration=${bamboo.buildConfiguration} /p:Platform=${bamboo.buildPlatform}
            

            The buildPlatform variable is specified with quotes, like this:

            "Any CPU"

            Log output from the task (still failing):

            command	06-Aug-2014 09:39:03	Substituting variable: ${bamboo.buildConfiguration} with Debug
            command	06-Aug-2014 09:39:03	Substituting variable: ${bamboo.buildPlatform} with "Any CPU"
            simple	06-Aug-2014 09:39:03	Starting task 'Build ERP.sln' of type 'com.atlassian.bamboo.plugin.dotnet:msbuild'
            command	06-Aug-2014 09:39:03	Beginning to execute external process for build 'ERP Lead Management - ERP-QA - Build QA branch #8 (ERPLEADS-ERPQA-JOB1-8)'\n ... running command line: \nC:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Debug /p:Platform="Any CPU" ERP.sln\n ... in: C:\build-dir\ERPLEADS-ERPQA-JOB1\ERPServices\n ... using extra environment variables:\nbamboo_buildPlatform="Any CPU"\n
            build	06-Aug-2014 09:39:07	Microsoft (R) Build Engine Version 4.0.30319.1
            build	06-Aug-2014 09:39:07	[Microsoft .NET Framework, Version 4.0.30319.269]
            build	06-Aug-2014 09:39:07	Copyright (C) Microsoft Corporation 2007. All rights reserved.
            build	06-Aug-2014 09:39:07	
            build	06-Aug-2014 09:39:07	MSBUILD : error MSB1008: Only one project can be specified.
            build	06-Aug-2014 09:39:07	Switch: ERP.sln
            build	06-Aug-2014 09:39:07	
            build	06-Aug-2014 09:39:07	For switch syntax, type "MSBuild /help"
            simple	06-Aug-2014 09:39:07	Failing task since return code of [C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Debug /p:Platform="Any CPU" ERP.sln] was 1 while expected 0
            simple	06-Aug-2014 09:39:07	Finished task 'Build ERP.sln' with result: Failed
            

            My workaround has been to run the following command from a Script task:

            C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ERP.sln /p:Configuration=${bamboo.buildConfiguration} /p:Platform=${bamboo.buildPlatform}
            

            This works, but I would like use the MSBuild task going forward.

            How do I get this to work?

            Uri Hendler added a comment - It still doesn't work for me. I'm running Bamboo OnDemand 5.6 (Version: 5.6-OD-01-0070; Build number: 4409). My MSBuild task config is: Executable: MSBuild v4.0 (32bit) Project File: ERP.sln Options: /p:Configuration=${bamboo.buildConfiguration} /p:Platform=${bamboo.buildPlatform} The buildPlatform variable is specified with quotes, like this: "Any CPU" Log output from the task (still failing): command 06-Aug-2014 09:39:03 Substituting variable: ${bamboo.buildConfiguration} with Debug command 06-Aug-2014 09:39:03 Substituting variable: ${bamboo.buildPlatform} with "Any CPU" simple 06-Aug-2014 09:39:03 Starting task 'Build ERP.sln' of type 'com.atlassian.bamboo.plugin.dotnet:msbuild' command 06-Aug-2014 09:39:03 Beginning to execute external process for build 'ERP Lead Management - ERP-QA - Build QA branch #8 (ERPLEADS-ERPQA-JOB1-8)' \n ... running command line: \nC:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Debug /p:Platform= "Any CPU" ERP.sln\n ... in: C:\build-dir\ERPLEADS-ERPQA-JOB1\ERPServices\n ... using extra environment variables:\nbamboo_buildPlatform= "Any CPU" \n build 06-Aug-2014 09:39:07 Microsoft (R) Build Engine Version 4.0.30319.1 build 06-Aug-2014 09:39:07 [Microsoft .NET Framework, Version 4.0.30319.269] build 06-Aug-2014 09:39:07 Copyright (C) Microsoft Corporation 2007. All rights reserved. build 06-Aug-2014 09:39:07 build 06-Aug-2014 09:39:07 MSBUILD : error MSB1008: Only one project can be specified. build 06-Aug-2014 09:39:07 Switch: ERP.sln build 06-Aug-2014 09:39:07 build 06-Aug-2014 09:39:07 For switch syntax, type "MSBuild /help" simple 06-Aug-2014 09:39:07 Failing task since return code of [C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Debug /p:Platform= "Any CPU" ERP.sln] was 1 while expected 0 simple 06-Aug-2014 09:39:07 Finished task 'Build ERP.sln' with result: Failed My workaround has been to run the following command from a Script task: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ERP.sln /p:Configuration=${bamboo.buildConfiguration} /p:Platform=${bamboo.buildPlatform} This works, but I would like use the MSBuild task going forward. How do I get this to work?

              pwatson paulwatson (Inactive)
              smaiyaki Sultan Maiyaki (Inactive)
              Affected customers:
              20 This affects my team
              Watchers:
              34 Start watching this issue

                Created:
                Updated:
                Resolved: