Skip to content

Commit

Permalink
Update build to be more consistent no matter how you build it.
Browse files Browse the repository at this point in the history
This is the initial change to switch to using common targets across the repo.

This change adds a dir.props and dir.targets file that each project file will
import at the top and bottom of the project to default a lot of the common properties
and targets.
  • Loading branch information
weshaggard committed Dec 18, 2014
1 parent 34b9c0c commit 3d95f9c
Show file tree
Hide file tree
Showing 20 changed files with 319 additions and 523 deletions.
57 changes: 7 additions & 50 deletions build.proj
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<BuildToolsVersion>1.0.16-prerelease</BuildToolsVersion>
<SkipTestAssemblies Condition="'$(SkipTestAssemblies)'==''">System.Threading.Tasks.Dataflow.Tests;System.Linq.Parallel.Tests</SkipTestAssemblies>
</PropertyGroup>

<PropertyGroup>
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
<SourceDir>$(ProjectDir)src\</SourceDir>
<BinDir>$(ProjectDir)bin\</BinDir>
<ToolsDir>$(BinDir)tools\</ToolsDir>

<NuGetToolPath>$(ToolsDir)NuGet.exe</NuGetToolPath>

<NuGetConfigFile>$(SourceDir)nuget\NuGet.Config</NuGetConfigFile>
<NuGetConfigCommandLine
Condition="Exists($(NuGetConfigFile))">-ConfigFile &quot;$(NuGetConfigFile)&quot;</NuGetConfigCommandLine>
<PackagesDir>$(SourceDir)packages\</PackagesDir>
</PropertyGroup>

<ItemGroup>
<PackageConfigs Include="$(SourceDir)*\packages.config" />
</ItemGroup>
<Import Project="dir.props" />

<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
Expand All @@ -44,35 +22,9 @@
</Task>
</UsingTask>

<Target Name="Clean">
<!-- Execute build tools -->
<MSBuild
Projects="$(ToolsDir)fxbuild.proj"
SkipNonexistentProjects="true"
Targets="Clean" />
</Target>

<Target Name="Build" DependsOnTargets="_RestoreBuildTools">
<!-- Execute build tools -->
<MSBuild
Projects="$(ToolsDir)fxbuild.proj"
Properties="SkipTestAssemblies=$(SkipTestAssemblies)"
Targets="Build" />
</Target>

<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

<Target Name="BuildFxLocalDependency" DependsOnTargets="_RestoreBuildTools" Returns="$(ProducedPackages)">
<!-- Execute build tools -->
<MSBuild
Projects="$(ToolsDir)fxbuild.proj"
Targets="BuildFxLocalDependency">
<Output TaskParameter="TargetOutputs" ItemName="ProducedPackages" />
</MSBuild>
</Target>

<Target
Name="_RestoreBuildTools"
BeforeTargets="Build;Clean"
Condition="!Exists('$(PackagesDir)Microsoft.DotNet.BuildTools.$(BuildToolsVersion)') Or !Exists('$(ToolsDir)fxbuild.proj')">
<!-- Download latest nuget.exe -->
<DownloadFile
Expand All @@ -90,4 +42,9 @@
Command="xcopy /e /y &quot;$(PackagesDir)Microsoft.DotNet.BuildTools.$(BuildToolsVersion)\lib\*&quot; &quot;$(ToolsDir)&quot; > &quot;$(ToolsDir)BuildTools.xcopy.log&quot;" />
</Target>

<ItemGroup>
<Project Include="src\dirs.proj" />
</ItemGroup>

<Import Project="dir.traversal.targets" />
</Project>
12 changes: 12 additions & 0 deletions dir.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
<SourceDir>$(ProjectDir)src\</SourceDir>
<BinDir>$(ProjectDir)bin\</BinDir>
<ToolsDir>$(BinDir)tools\</ToolsDir>

<NuGetToolPath>$(ToolsDir)NuGet.exe</NuGetToolPath>
<NuGetConfigFile>$(SourceDir)nuget\NuGet.Config</NuGetConfigFile>
<PackagesDir>$(SourceDir)packages\</PackagesDir>
</PropertyGroup>
</Project>
21 changes: 21 additions & 0 deletions dir.traversal.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

<Target Name="Build">
<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
however since the project names are unique it will essentially force each to run in its own batch -->
<MSBuild Targets="Build" Projects="@(Project)" Condition="'$(SerializeProjects)'=='true'" Properties="Dummy=%(Identity)"/>
<MSBuild Targets="Build" Projects="@(Project)" Condition="'$(SerializeProjects)'!='true'" BuildInParallel="true" />
</Target>

<Target Name="Clean">
<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
however since the project names are unique it will essentially force each to run in its own batch -->
<MSBuild Targets="Clean" Projects="@(Project)" Condition="'$(SerializeProjects)'=='true'" Properties="Dummy=%(Identity)"/>
<MSBuild Targets="Clean" Projects="@(Project)" Condition="'$(SerializeProjects)'!='true'" BuildInParallel="true" />
</Target>

<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

</Project>
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<!-- Work around known Dev14 bug - see
https://connect.microsoft.com/VisualStudio/feedback/details/1000796/connect-file-uap-props-not-found-cant-build-a-portable-lib-on-vs14
-->
<_WindowsKitBinPath>$(MSBuildProgramFiles32)\Windows Kits\8.1\bin\x86</_WindowsKitBinPath>
<_WindowsPhoneKitBinPath>$(MSBuildProgramFiles32)\Windows Phone Kits\8.1\bin</_WindowsPhoneKitBinPath>
<MakePriExeFullPath>$(_WindowsKitBinPath)\makepri.exe</MakePriExeFullPath>
<MakeAppxExeFullPath>$(_WindowsKitBinPath)\makeappx.exe</MakeAppxExeFullPath>
<SignAppxPackageExeFullPath>$(_WindowsKitBinPath)\signtool.exe</SignAppxPackageExeFullPath>
<MakePriExtensionPath>$(_WindowsPhoneKitBinPath)\x86\MrmEnvironmentExtDl.dll</MakePriExtensionPath>
<MakePriExtensionPath_x64>$(_WindowsPhoneKitBinPath)\x64\MrmEnvironmentExtDl.dll</MakePriExtensionPath_x64>
</PropertyGroup>
<Import Project="..\..\dir.props" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -26,7 +14,6 @@
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)bin\$(Configuration)\$(AssemblyName)\</OutputPath>
<DocumentationFile>$(OutputPath)System.Collections.Immutable.xml</DocumentationFile>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
Expand Down Expand Up @@ -133,12 +120,5 @@
<ItemGroup>
<None Include="Interfaces.cd" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\dir.targets" />
</Project>
70 changes: 22 additions & 48 deletions src/System.Console/src/System.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,56 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<!-- Work around known Dev14 bug - see
https://connect.microsoft.com/VisualStudio/feedback/details/1000796/connect-file-uap-props-not-found-cant-build-a-portable-lib-on-vs14
-->
<_WindowsKitBinPath>$(MSBuildProgramFiles32)\Windows Kits\8.1\bin\x86</_WindowsKitBinPath>
<_WindowsPhoneKitBinPath>$(MSBuildProgramFiles32)\Windows Phone Kits\8.1\bin</_WindowsPhoneKitBinPath>
<MakePriExeFullPath>$(_WindowsKitBinPath)\makepri.exe</MakePriExeFullPath>
<MakeAppxExeFullPath>$(_WindowsKitBinPath)\makeappx.exe</MakeAppxExeFullPath>
<SignAppxPackageExeFullPath>$(_WindowsKitBinPath)\signtool.exe</SignAppxPackageExeFullPath>
<MakePriExtensionPath>$(_WindowsPhoneKitBinPath)\x86\MrmEnvironmentExtDl.dll</MakePriExtensionPath>
<MakePriExtensionPath_x64>$(_WindowsPhoneKitBinPath)\x64\MrmEnvironmentExtDl.dll</MakePriExtensionPath_x64>
</PropertyGroup>
<Import Project="..\..\dir.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9DF2357-81B4-4317-908E-512DA9395583}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>System.Console</RootNamespace>
<AssemblyName>System.Console</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)bin\$(Configuration)\$(AssemblyName)\</OutputPath>
<ImplicitlyExpandTargetFramework>False</ImplicitlyExpandTargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<CommonPath>..\..\Common\src</CommonPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Diagnostics.Contracts">
<HintPath>..\..\packages\System.Diagnostics.Contracts.4.0.0-beta-22405\lib\portable-wpa80+win80+net45+aspnetcore50\System.Diagnostics.Contracts.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Diagnostics.Debug">
<HintPath>..\..\packages\System.Diagnostics.Debug.4.0.10-beta-22405\lib\portable-wpa80+win80+net45+aspnetcore50\System.Diagnostics.Debug.dll</HintPath>
Expand Down Expand Up @@ -129,7 +98,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonPath)\System\SR.cs" />
<Compile Include="$(CommonPath)\System\SR.cs">
<Link>Common\System\SR.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Strings.resx">
Expand Down Expand Up @@ -157,22 +128,25 @@
<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
<Compile Include="System\ConsolePal.Windows.cs" />
<Compile Include="Interop\Interop.manual.Windows.cs" />
<Compile Include="$(CommonPath)\System\IO\Win32Marshal.cs" />
<Compile Include="$(CommonPath)\System\IO\Win32Marshal.cs">
<Link>Common\System\IO\Win32Marshal.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition=" '$(OS)' == 'Unix' ">
<Compile Include="System\ConsolePal.Unix.cs" />
<Compile Include="Interop\Interop.manual.Unix.cs" />
<Compile Include="$(CommonPath)\Interop\Interop.CoreFileIO.Unix.cs" />
<Compile Include="$(CommonPath)\Interop\Interop.Errors.Unix.cs" />
<Compile Include="$(CommonPath)\Interop\Interop.strerror.Unix.cs" />
<Compile Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
<Compile Include="$(CommonPath)\Interop\Interop.CoreFileIO.Unix.cs">
<Link>Common\Interop\Interop.CoreFileIO.Unix.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Interop.Errors.Unix.cs">
<Link>Common\Interop\Interop.Errors.Unix.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Interop.strerror.Unix.cs">
<Link>Common\Interop\Interop.strerror.Unix.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs">
<Link>Common\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\dir.targets" />
</Project>
45 changes: 10 additions & 35 deletions src/System.Linq.Parallel/src/System.Linq.Parallel.csproj
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<!-- Work around known Dev14 bug - see
https://connect.microsoft.com/VisualStudio/feedback/details/1000796/connect-file-uap-props-not-found-cant-build-a-portable-lib-on-vs14
-->
<_WindowsKitBinPath>$(MSBuildProgramFiles32)\Windows Kits\8.1\bin\x86</_WindowsKitBinPath>
<_WindowsPhoneKitBinPath>$(MSBuildProgramFiles32)\Windows Phone Kits\8.1\bin</_WindowsPhoneKitBinPath>
<MakePriExeFullPath>$(_WindowsKitBinPath)\makepri.exe</MakePriExeFullPath>
<MakeAppxExeFullPath>$(_WindowsKitBinPath)\makeappx.exe</MakeAppxExeFullPath>
<SignAppxPackageExeFullPath>$(_WindowsKitBinPath)\signtool.exe</SignAppxPackageExeFullPath>
<MakePriExtensionPath>$(_WindowsPhoneKitBinPath)\x86\MrmEnvironmentExtDl.dll</MakePriExtensionPath>
<MakePriExtensionPath_x64>$(_WindowsPhoneKitBinPath)\x64\MrmEnvironmentExtDl.dll</MakePriExtensionPath_x64>
</PropertyGroup>

<Import Project="..\..\dir.props" />
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
<ProjectGuid>{BE28323E-327A-4E0F-B7F9-16AB7EAB59DD}</ProjectGuid>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AssemblyName>System.Linq.Parallel</AssemblyName>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)bin\$(Configuration)\$(AssemblyName)\</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitlyExpandTargetFramework>False</ImplicitlyExpandTargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DebugType>full</DebugType>

<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>

<!-- Contract references used -->
Expand Down Expand Up @@ -267,11 +242,11 @@

<!-- Common or Common-branched source files -->
<ItemGroup>
<Compile Include="..\..\Common\src\System\SR.cs">
<Link>System\SR.cs</Link>
<Compile Include="$(CommonPath)\System\SR.cs">
<Link>Common\System\SR.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\System\ArrayT.cs">
<Link>System\ArrayT.cs</Link>
<Compile Include="$(CommonPath)\System\ArrayT.cs">
<Link>Common\System\ArrayT.cs</Link>
</Compile>
</ItemGroup>

Expand All @@ -285,5 +260,5 @@
</EmbeddedResource>
</ItemGroup>

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\dir.targets" />
</Project>
Loading

0 comments on commit 3d95f9c

Please sign in to comment.