Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement imports for project extensions #994

Merged
merged 2 commits into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 69 additions & 61 deletions src/XMakeBuildEngine/UnitTests/EscapingInProjects_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,23 +919,23 @@ public class FullProjectsUsingMicrosoftCommonTargets
Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `Class;!@(foo)'^(Library1`, `Class;!@(foo)'^(Library1\Class;!@(foo)'^(Library1.csproj`, `{0B4B78CC-C752-43C2-BE9A-319D20216129}`
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Release|Any CPU.Build.0 = Release|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{770F2381-8C39-49E9-8C96-0538FA4349A7}.Release|Any CPU.Build.0 = Release|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B4B78CC-C752-43C2-BE9A-319D20216129}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
";

Expand All @@ -952,6 +952,7 @@ public void SemicolonInConfiguration()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -975,9 +976,9 @@ public void SemicolonInConfiguration()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1016,6 +1017,7 @@ public void SemicolonInConfiguration_UsingTaskHost()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1039,9 +1041,9 @@ public void SemicolonInConfiguration_UsingTaskHost()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1080,6 +1082,7 @@ public void SemicolonInAssemblyName()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1103,9 +1106,9 @@ public void SemicolonInAssemblyName()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1138,6 +1141,7 @@ public void SemicolonInAssemblyName_UsingTaskHost()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1161,9 +1165,9 @@ public void SemicolonInAssemblyName_UsingTaskHost()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1196,6 +1200,7 @@ public void DollarSignInAssemblyName()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1219,9 +1224,9 @@ public void DollarSignInAssemblyName()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1254,6 +1259,7 @@ public void DollarSignInAssemblyName_UsingTaskHost()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1277,9 +1283,9 @@ public void DollarSignInAssemblyName_UsingTaskHost()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1312,6 +1318,7 @@ public void SemicolonInSourceCodeFilename()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1335,9 +1342,9 @@ public void SemicolonInSourceCodeFilename()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class;1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1370,6 +1377,7 @@ public void SemicolonInSourceCodeFilename_UsingTaskHost()
// ---------------------
ObjectModelHelpers.CreateFileInTempProjectDirectory("foo.csproj", @"
<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
<Import Project=`$(MSBuildBinPath)\Microsoft.Common.props` />
<PropertyGroup>
<Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration>
<Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform>
Expand All @@ -1393,9 +1401,9 @@ public void SemicolonInSourceCodeFilename_UsingTaskHost()
ObjectModelHelpers.CreateFileInTempProjectDirectory("Class;1.cs", @"
namespace ClassLibrary16
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1499,13 +1507,13 @@ public void SolutionWithLotsaCrazyCharacters()

namespace Console____foo____Application1
{
class Program
{
static void Main(string[] args)
{
Class____foo____Library1.Class1 foo = new Class____foo____Library1.Class1();
}
}
class Program
{
static void Main(string[] args)
{
Class____foo____Library1.Class1 foo = new Class____foo____Library1.Class1();
}
}
}
");

Expand Down Expand Up @@ -1566,9 +1574,9 @@ static void Main(string[] args)
@"
namespace Class____foo____Library1
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down Expand Up @@ -1670,13 +1678,13 @@ public void SolutionWithLotsaCrazyCharacters_UsingTaskHost()

namespace Console____foo____Application1
{
class Program
{
static void Main(string[] args)
{
Class____foo____Library1.Class1 foo = new Class____foo____Library1.Class1();
}
}
class Program
{
static void Main(string[] args)
{
Class____foo____Library1.Class1 foo = new Class____foo____Library1.Class1();
}
}
}
");

Expand Down Expand Up @@ -1737,9 +1745,9 @@ static void Main(string[] args)
@"
namespace Class____foo____Library1
{
public class Class1
{
}
public class Class1
{
}
}
");

Expand Down
2 changes: 0 additions & 2 deletions src/XMakeTasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<PropertyGroup>
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
<AutoUnifyAssemblyReferences Condition="'$(GenerateBindingRedirectsOutputType)' == 'true' and '$(AutoGenerateBindingRedirects)' != 'true'">false</AutoUnifyAssemblyReferences>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="!HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
<CleanFile Condition="'$(CleanFile)'==''">$(MSBuildProjectFile).FileListAbsolute.txt</CleanFile>
<!-- During DesignTime Builds, skip project reference build as Design time is only queueing information.-->
<BuildProjectReferences Condition="'$(BuildProjectReferences)' == '' and '$(DesignTimeBuild)' == 'true'">false</BuildProjectReferences>
Expand Down
27 changes: 27 additions & 0 deletions src/XMakeTasks/Microsoft.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Import Project="$(DirectoryBuildPropsPath)" Condition="'$(ImportDirectoryBuildProps)' == 'true' and exists('$(DirectoryBuildPropsPath)')"/>

<!--
Prepare to import project extensions which usually come from packages. Package management systems will create a file at:
$(MSBuildProjectExtensionsPath)\$(MSBuildProjectFile).<SomethingUnique>.props

Each package management system should use a unique moniker to avoid collisions. It is a wild-card import so the package
management system can write out multiple files but the order of the import is alphabetic because MSBuild sorts the list.
-->
<PropertyGroup>
<!--
The declaration of $(BaseIntermediateOutputPath) had to be moved up from Microsoft.Common.CurrentVersion.targets
Copy link
Member

@rainersigwald rainersigwald Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says "moved" but I don't see a corresponding delete. Intentional? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't sure if it was safe to remove it from Microsoft.Common.CurrentVersion.targets. Is there a way to confirm that it is safe?


In reply to: 77846900 [](ancestors = 77846900)

Copy link
Member

@rainersigwald rainersigwald Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it and listen for screams?

Seriously: I don't know of a good way to guarantee that. But since common.targets imports common.props if it's not already in the project it seems safe, because the new codepath should always get hit. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll keep my ears open :)


In reply to: 77850989 [](ancestors = 77850989)

in order for the $(MSBuildProjectExtensionsPath) to use it as a default.
-->
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="!HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath Condition="'$(MSBuildProjectExtensionsPath)' == '' ">$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
<!--
Import paths that are relative default to be relative to the importing file. However, since MSBuildExtensionsPath
defaults to BaseIntermediateOutputPath we expect it to be relative to the project directory. So if the path is relative
it needs to be made absolute based on the project directory.
Copy link
Member

@rainersigwald rainersigwald Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 #Closed

-->
<MSBuildProjectExtensionsPath Condition="'$([System.IO.Path]::IsPathRooted($(MSBuildProjectExtensionsPath)))' == 'false'">$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(MSBuildProjectExtensionsPath)'))</MSBuildProjectExtensionsPath>
<MSBuildProjectExtensionsPath Condition="!HasTrailingSlash('$(MSBuildProjectExtensionsPath)')">$(MSBuildProjectExtensionsPath)\</MSBuildProjectExtensionsPath>
<ImportProjectExtensionProps Condition="'$(ImportProjectExtensionProps)' == ''">true</ImportProjectExtensionProps>
</PropertyGroup>

<Import Project="$(MSBuildProjectExtensionsPath)$(MSBuildProjectFile).*.props" Condition="'$(ImportProjectExtensionProps)' == 'true' and exists('$(MSBuildProjectExtensionsPath)')" />
Copy link
Member

@eerhardt eerhardt Sep 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we decided on an ordering mechanism here? Or is it up to each package manager to order inside their generated .props file? (please don't block this PR on this question)

What is the ordering of a wildcard import? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was up to the OS but it turns out we sort them...

https://github.com/Microsoft/msbuild/blob/31122efbd2cb79988ecacc7406a1c16ca34d4b34/src/OrcasEngine/Utilities/EngineFileUtilities.cs#L64


In reply to: 77725944 [](ancestors = 77725944)


<!--
Import wildcard "ImportBefore" props files if we're actually in a 12.0+ project (rather than a project being
treated as 4.0)
Expand Down
13 changes: 13 additions & 0 deletions src/XMakeTasks/Microsoft.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Import Project="$(CommonTargetsPath)" />

<!--
Prepare to import project extensions which usually come from packages. Package management systems will create a file at:
$(MSBuildProjectExtensionsPath)\$(MSBuildProjectFile).<SomethingUnique>.targets

Each package management system should use a unique moniker to avoid collisions. It is a wild-card import so the package
management system can write out multiple files but the order of the import is alphabetic because MSBuild sorts the list.
-->
<PropertyGroup>
<ImportProjectExtensionTargets Condition="'$(ImportProjectExtensionTargets)' == ''">true</ImportProjectExtensionTargets>
</PropertyGroup>

<Import Project="$(MSBuildProjectExtensionsPath)$(MSBuildProjectFile).*.targets" Condition="'$(ImportProjectExtensionTargets)' == 'true' and exists('$(MSBuildProjectExtensionsPath)')" />

<PropertyGroup>
<ImportDirectoryBuildTargets Condition="'$(ImportDirectoryBuildTargets)' == ''">true</ImportDirectoryBuildTargets>
</PropertyGroup>
Expand Down
10 changes: 6 additions & 4 deletions src/XMakeTasks/UnitTests/Microsoft.Build.Tasks.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" Condition="!$(Configuration.EndsWith('MONO'))"/>
Expand Down Expand Up @@ -74,6 +74,9 @@
<Compile Include="Move_Tests.cs" />
<Compile Include="MSBuild_Tests.cs" />
<Compile Include="PortableTasks_Tests.cs" />
<Compile Include="ProjectExtensionsImportTestBase.cs" />
<Compile Include="ProjectExtensionsPropsImportTest.cs" />
<Compile Include="ProjectExtensionsTargetsImportTest.cs" />
<Compile Include="PropertyParser_Tests.cs" />
<Compile Include="ReadLinesFromFile_Tests.cs" />
<Compile Include="RemoveDir_Tests.cs" />
Expand All @@ -85,7 +88,6 @@
<Compile Include="Touch_Tests.cs" />
<Compile Include="TrustInfo_Tests.cs" />
<Compile Include="WriteCodeFragment_Tests.cs" />

<EmbeddedResource Include="SampleResx" />
<None Include="..\..\Shared\UnitTests\App.config">
<Link>App.config</Link>
Expand Down Expand Up @@ -125,7 +127,7 @@
<Compile Include="MockTypeLib.cs" />
<Compile Include="ResGen_Tests.cs" />
<Compile Include="ResGenDependencies_Tests.cs" />
<Compile Include="AssemblyDependency\AssemblyFoldersFromConfig_Tests.cs" />
<Compile Include="AssemblyDependency\AssemblyFoldersFromConfig_Tests.cs" />
<Compile Include="AssemblyDependency\FilePrimary.cs" />
<Compile Include="AssemblyDependency\GlobalAssemblyCacheTests.cs" />
<Compile Include="AssemblyDependency\InstalledSDKResolverFixture.cs" />
Expand Down Expand Up @@ -188,4 +190,4 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="..\..\dir.targets" />
</Project>
</Project>
Loading