Search code examples
msbuildxamarinxamarin-studioxbuild

How to make XamarinStudio generate object files into a seperate directory?


Let's take this one by example. I'm developing on linux and using XamarinStudio for all of my .NET projects. I like it more than having VisualStudio running in the virtual machine. I have a solution that has several projects in it, that looks like this:

/Solution
/Solution/Project1 -> project number 1
/Solution/Project2 -> project number 2
/Solution/Project3 -> project number 3
/Solution/Output   -> output folder for all projects
/Solution/Temp     -> temporary files for all projects

I'm able to set the output directory for all projects, but I don't know how to set projects to generate temporary files to the Temp folder. Right now temporary files are generated into /Solution/ProjectX/obj/x86/Debug/ and /Solution/ProjectX/obj/x86/Debug/. How can I change it? I couldn't find the way to set it in the project/solution properties.


Solution

  • If you are using MSBuild to build your projects from within Xamarin Studio then you can use the IntermediateOutputPath element in the project file (.csproj) to override the default directory where obj files are stored.

    <IntermediateOutputPath>..\Temp\ProjectX\obj\$(Configuration)\</IntermediateOutputPath>
    

    You can change where obj files are saved by editing the project file (.csproj) in a text editor and adding the IntermediateOutputPath so it points to your temp directory. You will probably want to have different directories for each project.

    I tried this with Xamarin Studio 5.7 with Mono 3.12 on the Mac and it seems to work. This should also work with Visual Studio.