Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An auto-imported solution targets file to stop Team Build from overriding the OutDir property. Just put this file in your solution folder and rename 'TheSolution' to match the solution filename.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask Condition="'$(OutDir)' != ''"
TaskName="MSBuild"
TaskFactory="CodeTaskFactory"
AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<ParameterGroup>
<Projects ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<BuildInParallel ParameterType="System.Boolean" />
<Properties ParameterType="System.String[]" />
<SkipNonexistentProjects ParameterType="System.String" />
<TargetOutputs ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
<Targets ParameterType="System.String[]" />
</ParameterGroup>
<Task>
<Reference Include="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var newProperties = new System.Collections.Generic.List<string>(Properties);
newProperties.Add(@"PreferredOutDir=$(OutDir)");
var childTask = new Microsoft.Build.Tasks.MSBuild();
childTask.BuildEngine = BuildEngine;
childTask.Projects = Projects;
childTask.BuildInParallel = BuildInParallel;
childTask.Properties = newProperties.ToArray();
childTask.SkipNonexistentProjects = SkipNonexistentProjects;
childTask.Targets = Targets;
childTask.RemoveProperties = "OutDir"; // Magic happens here!
var result = childTask.Execute();
TargetOutputs = childTask.TargetOutputs;
return result;
]]>
</Code>
</Task>
</UsingTask>
</Project>
@mfuxi

This comment has been minimized.

Copy link

commented Apr 27, 2015

For most of my projects this solution works great, but I got one project which has build errors because of this addition to my solution directory.

The Error are like these for several projects: *****.csproj.metaproj: The project file could not be loaded. Could not find file ****.csproj.metaproj'.

Do u have any idea?

10x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.