How do I pass multiple ReferencePath in MSBuild in the command line. I'm currently using this
MSBuild /t:Rebuild "Solution1.sln" /p:ReferencePath="C:\My Library 1\obj\Debug; C:\My Library 2\obj\Debug"
MSBuild is returning an MSB1006 error. Take note that my reference paths have spaces in it.
Try escaping the semicolons as %3b
Try moving the quotes around the entire property expression, not just the values
/p:"Name=Value One;Value Two"
I had the same problem. This worked for me:
msbuild {{slnPath}} /t:rebuild /p:OutDir={{outputpath}} /p:Configuration=Release
Specify /p for every parameter
This wasn't working in powershell
msbuild C:\temp\project.sln /p:referencepath="C:\Checkout\References
\CRM 2011;C:\Checkout\References\Log4Net\4.0\release"
but works fine from an old fashioned cmd prompt.
No matter what I do, I can't seem to make it work using MSBuild. I now use DEVENVE.EXE to compile my solution; it would read my user project settings where the ReferencePath is saved and use that to locate the correct version of the DLL I want to use.
replacing the ';' with '3%B' seems to work in my setup with Nant and Jenkins
Related
I'm looking for a way to run a WebDeploy call from within my MsBuild target, with the WebDeploy call having nothing to do with the application being built.
I have a commandline msdeploy which looks like this:
msdeploy.exe –verb:sync
-source:contentPath="C:\MyFolderPath"
-dest:contentPath="C:\MyDestinationPath"
This works perfectly. Now I want to plug this into an msbuild file into the AfterBuild target:
<MSDeploy Verb="Sync"
Source="-contentPath:'C:\MyFolderPath'"
Destination="-contentPath:'C:\MyDestinationPath'" />
This gives me ERROR_PROVIDER_NOT_FOUND when I build. I've tried the -contentPath both with and without the -
I can't seem to find the documentation for the MsDeploy task though which isn't helping. Any help much appreciated
Delete the dashes ("-") in the Source and Destination attributes. You may also need to use escaped double quotes instead of single quotes but you can try it both ways:
<MSDeploy
Verb="sync"
Source="dirPath=%22$(FilesToPackageFolder)%22"
Destination="package=%22%(DeployTypes.DeployPackagePath)%22"
/>
I'm running the following msbuild command
msbuild /verbosity:normal /property:configuration="Release"
/property:VisualStudioVersion="12.0" /m /property:RunOctoPack="true"
/property:OctoPackEnforceAddingFiles="true" /target:"Clean" ../MYSLN.sln
which builds successfully.
I just tried running the same command using xbuild on OSX so:
xbuild /verbosity:normal /property:configuration="Release"
/property:VisualStudioVersion="12.0" /m /property:RunOctoPack="true"
/property:OctoPackEnforceAddingFiles="true" /target:"Clean" ../MYSLN.sln
which reports
MSBUILD: error MSBUILD0004: Too many project files specified
I have XBuild Engine Version 12.0 and Mono, Version 4.0.2.0
Is there some subtle mistake in how I'm listing the parameters
----EDIT----
That's being thrown here: https://github.com/mono/mono/blob/master/mcs/tools/xbuild/Parameters.cs#L140 which suggests that xbuild isn't picking up the solution file (I think)
NB, I've tried with the solution file as the first and last parameter to no avail
----EDIT----
I've added that the solution file has an uppercase name in case that is important.
----EDIT----
Ah, I've been writing a test around their parameter parsing code and it isn't recognising /m
So, I grabbed their source and wrote a test to see what was happening. And xamarin doesn't recognise the /m parameter. That's a real parameter for xbuild so I've logged https://bugzilla.xamarin.com/show_bug.cgi?id=33388 to see if they purposefully don't support it
TLDR; currently xbuild doesn't support /m as a parameter
I can see that MSBuild makes use of the /t:Package on the command line, but what's the euivalent for including this option in an msbuild script file.
The equivalent in a build script file is to use the MsBuild task. See link below.
Msdn Build Task
Are you invoking an msbuild script from another script using the MsBuild task? If so, the parameter you want to use is Targets http://msdn.microsoft.com/en-us/library/z7f65y0d.aspx.
Note: I'm using Mercurial as an example here, because that's what I'm trying to get to work with MSBuild right now.
But the problem is not limited to Mercurial, it happens with every external program that is somewhere in my %PATH% variable (I tried the same with PowerShell, for example).
So I didn't put the Mercurial tag on this question on purpose, because this is not about Mercurial!
What I actually want to do:
I want my build script to get the current revision number from my Mercurial repository and store it in a file.
The simplest way to do this from the command line is:
hg id -i >rev.txt
Mercurial is installed on my machine and the installation folder is in my %PATH% variable.
So I can run this line from anywhere on my machine (directly from the command line, or from a batch file), and it just works.
The problem occurs when I try to run this line from my build script.
I change the BeforeBuild (or AfterBuild) section of my .csproj file as follows:
<Target Name="AfterBuild">
<Exec Command="hg id -i >rev.txt"/>
</Target>
When I compile my solution with Visual Studio, it works and the rev.txt file is created in the folder where my .csproj is.
But when I compile the exact same solution from the command line with MSBuild, the build fails with the following error message:
The command "hg id -i >rev.txt" exited with code 9009.
I googled "msbuild code 9009" and found some solutions, but all of them propose to provide the full path to the executable.
When I do this, the build succeeds with MSBuild as well.
But this is not an acceptable solution for me, because I can't be sure that everyone using my project (including the build server) has installed Mercurial in the exact same folder.
That's exactly what %PATH% is for...
The same happens when I put the <Exec Command="... line directly into the build script.
If I specify the path to the executable, it works.
If I don't specify the path, it doesn't.
Is there any trick to make MSBuild execute programs in my %PATH% variable without specifying the complete folder?
EDIT:
#leppie:
Output redirection:
You mean the fact that I save the output of my command in a text file inside the command , instead of just running hg id -i as a command and using an output parameter or something like that to get the output?
Doesn't make any difference...the error is the same when I omit >rev.txt.
Command line args:
No, it throws the same error, even if I shorten the command to just hg (without any parameters).
Don't forget: if I run the exact same Exec command in the exact same .csproj file from Visual Studio, or if I just provide the path to the .exe file in the command, everything works.
So IMO output redirection and command line args can't be the problem.
Have you tried this extension pack for mercurial/msbuild?
http://msbuildhg.codeplex.com/documentation
Seems to have a task for returning revision id, which is what your trying to achieve no?
<HgVersion LocalPath="$(MSBuildProjectDirectory)" Timeout="5000">
<Output TaskParameter="Revision" PropertyName="AssemblyRevision" />
</HgVersion>
Okay, I found the solution.
I have to admit, it was a classic case of PEBKAC :-)
I'll explain it anyway, maybe it will help someone who made the same mistake:
Basically everything I have tried (plus what James Woolfenden suggested in his answer) would have been worked...if only the batch file that I use to run the build script wouldn't have looked like this:
path="%windir%\Microsoft.net\Framework\v4.0.30319"
msbuild build.proj
Yes, exactly.
I'm editing the %PATH% variable for the duration of this batch file, and I'm overwriting it with the path to MSBuild instead of just appending it.
So when my build script tries to call Mercurial, it can't find it anymore because its location is not in the %PATH% variable anymore.
No idea why I didn't see this before.
The correct way would be to append the MSBuild path, leaving the other paths intact:
path=%path%;%windir%\Microsoft.net\Framework\v4.0.30319
I know that I can pass MSBuild a VS solution file (.sln) and it will build the solution but somewhere in the back of my mind, I remember using a MSBuild command line switch that would take a solution file (and it's referenced project files) and generate a single MSBuild project file from them. However, I now can't find this switch!
Was this all a dream?
I see the /preprocess switch (short form /pp) but I don't think that this was it as this will include all of the imported files (including Microsoft.*.targets) and besides I can't seem to get this switch to work. I when I try the following command line, MSbuild generates the *.out file but its empty!
msbuild /target:rebuild /generate MSBuildCopyTargets.sln
The easiest way to do this is to run MSBuild from the command line, with an environment variable set:
Set MSBuildEmitSolution=1
The output will be in the format SolutionName.metaproj