Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Convert all projects to SDK-style #29831

Merged
merged 27 commits into from
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91d7e62
Convert all .csproj files in src to SDK-style projects
wtgodbe May 21, 2018
be0421d
Add Directory.build.props/targets
wtgodbe May 21, 2018
f60fa38
Add project.assets.json & edit properties
wtgodbe May 21, 2018
10b7151
Remove project.assets.json file
wtgodbe May 21, 2018
3ecd281
Get netcoreapp build working.
eerhardt Jun 11, 2018
ad505eb
Merge master into SdkProj
eerhardt Jun 11, 2018
be5ceb5
Clean up projects. Get all projects importing clean with no warnings…
eerhardt Jun 12, 2018
204a8db
Rename dir files to Directory.Build
eerhardt Jun 15, 2018
1c91f96
merge master into SdkProj
eerhardt Jun 16, 2018
3b36996
Small fixes to get the build clean.
eerhardt Jun 16, 2018
b09b0b5
Fix AssemblySearchPaths on the Microsoft.NET.Sdk.
eerhardt Jun 16, 2018
67dacd6
Ensure csc command line is the same as before converting to Sdk proje…
eerhardt Jun 19, 2018
0c7364e
Merge master into SdkProj
eerhardt Jun 19, 2018
53d5973
Fix FileVersionInfo build
eerhardt Jun 19, 2018
6d25667
Rephrase Directory.Build comments to better describe why ImportDirect…
eerhardt Jun 20, 2018
e05508a
Change .csproj to new Configurations property
eerhardt Jun 28, 2018
9f65193
Turn off ILLinkTrimAssembly during design-time builds.
eerhardt Jun 29, 2018
ec546de
Merge master into SdkProj
eerhardt Jun 29, 2018
860888c
Fix up Reflection.Context dir.props/targets to Directory.Build.
eerhardt Jun 29, 2018
6ccae92
Revert WebServer change, since it cannot be an SDK style project.
eerhardt Jun 29, 2018
0343b37
Merge master into SdkProj
eerhardt Jul 5, 2018
1a4b8a2
Run UpdateVSConfigurations on the current code.
eerhardt Jul 5, 2018
9b7b8c0
Fix up new projects and usages of dir.props/targets.
eerhardt Jul 5, 2018
e72643b
Merge master into SdkProj
eerhardt Jul 6, 2018
aa89672
Set TargetFramework to workaround project system bug.
eerhardt Jul 6, 2018
b86cade
Merge remote-tracking branch 'upstream/master' into SdkProj
eerhardt Jul 6, 2018
99e21e6
Merge master into SdkProj
eerhardt Jul 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@
<SymbolPackageOutputPath Condition="'$(SymbolPackageOutputPath)'==''">$(PackageOutputPath)symbols/</SymbolPackageOutputPath>
</PropertyGroup>

<!-- Set up default paths for reference assemblies -->
<PropertyGroup Condition="'$(IsReferenceAssembly)'=='true'">
<!-- Create a common root output directory for all reference assemblies -->
<ReferenceAssemblyOutputPath Condition="'$(ReferenceAssemblyOutputPath)' == ''">$(BaseOutputPath)ref/</ReferenceAssemblyOutputPath>
<TargetOutputRelPath Condition="'$(IsCompatAssembly)'=='true'">$(TargetOutputRelPath)Compat/</TargetOutputRelPath>
<OutputPath>$(ReferenceAssemblyOutputPath)$(MSBuildProjectName)/$(TargetOutputRelPath)</OutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)ref/$(AssemblyName)/$(TargetOutputRelPath)</IntermediateOutputPath>
</PropertyGroup>

<!-- Properties related to multi-file mode for ILC tests -->
<PropertyGroup Condition="'$(TargetGroup)' == 'uapaot'">
<!-- Only enable multi-file for Release-x64 and Debug-x86 for now -->
Expand Down
7 changes: 2 additions & 5 deletions src/Common/perf/PerfRunner/PerfRunner.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt are you aware of any way we can avoid setting this string in all our projects? We are very likely going to need to move to another SDK as part of our arcade repo and it would be great if we could just change it in one place in the repo if possible.

Copy link

Choose a reason for hiding this comment

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

Based on dotnet/msbuild#1493, we can use <Import> semantics, because in Project Sdk="$(prop)", prop does not be evaluated, nor in <Sdk Name="$(prop)">. Alternatively, we can implement ISdkResolver when it is implemented in MSBuild. :)

Copy link
Member

Choose a reason for hiding this comment

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

You can do something like the following commit:

eerhardt/machinelearning@ed3c014

This allows my .csproj files to be built from the command line using dotnet build.

However, VS 2017 throws an error trying to load this project:

---------------------------
Microsoft Visual Studio
---------------------------
Project file is incomplete. Expected imports are missing.
---------------------------
OK   
---------------------------

@davkean - Any thoughts on this VS error?

@weshaggard - honestly, I think attempting to put the SDK name in a single place is going to be an uphill battle, and I'm not sure it is worth the effort. Yes, it will change one, maybe two more times. But IMO the work and effort of find/replace in a few hundred files is less than trying to do things that the tools weren't designed to support. And note that you need 2 imports in every .csproj with my approach above (props on top, targets on bottom).

Copy link
Member

Choose a reason for hiding this comment

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

I agree it isn't a big deal. We should however be sure to keep the version out of all the project files as we we need to be able to override that in some cases like source-build so lets keep the version in the global.json file.

Copy link
Member

Choose a reason for hiding this comment

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

The error above indicates that you are not importing Microsoft.Common.targets and indirectly Microsoft.Managed.DesignTime.targets. You can verify this by doing a msbuild /pp on the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can import the SDK in a central props/targets, but then the central props/targets can't be Directory.Build.*. Chicken and egg. Sdk imports common targets and common targets imports Directory.Build.*

If you use explicit dir.props/dir.targets, then you can do this: nguerrera/sdkimportrepro@6d34578

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see that @eerhardt explicitly imported Directory.Build.* and then turned off the magic import. That should have worked too. My above commit with different name for explicit directory props/targets is working fine in VS. Let me try @eerhardt's approach in that sandbox.

Copy link
Contributor

Choose a reason for hiding this comment

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

nguerrera/sdkimportrepro@ab90e62 works fine in VS for me too. I cannot repro what @eerhardt is seeing with that approach.

Copy link
Member

Choose a reason for hiding this comment

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

I tried it on today's daily dogfood build, and am no longer seeing the error. The project loads and builds correctly in VS.

<PropertyGroup>
<ProjectGuid>{F5E941C8-AF2F-47AB-A066-FF25470CE382}</ProjectGuid>
<OutputType>Exe</OutputType>
Expand Down Expand Up @@ -29,5 +27,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
7 changes: 2 additions & 5 deletions src/Common/tests/Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{C72FD34C-539A-4447-9796-62A229571199}</ProjectGuid>
<TestCategories>InnerLoop;OuterLoop</TestCategories>
Expand Down Expand Up @@ -150,5 +148,4 @@
<Name>RemoteExecutorConsoleApp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
5 changes: 1 addition & 4 deletions src/Common/tests/Performance/Common.Performance.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IncludePerformanceTests>true</IncludePerformanceTests>
<ProjectGuid>{B96198F5-9BF7-42DE-83E8-3EE39DA25F43}</ProjectGuid>
Expand All @@ -23,5 +21,4 @@
<Name>PerfRunner</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{8DE22889-A6CB-41EC-B807-D44A2C184719}</ProjectGuid>
<OutputType>Exe</OutputType>
Expand All @@ -25,5 +23,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -191,5 +189,4 @@
</Target>
-->
<Target Name="AnnotateProjectsWithConfiguration" />
<Target Name="FindBestConfiguration" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{42F10363-C2A2-42B5-B7B9-1B5DBB0BC71E}</ProjectGuid>
<RootNamespace>WebData.BaseLib</RootNamespace>
Expand All @@ -13,5 +11,4 @@
<Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAssemblyAttribute.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
7 changes: 2 additions & 5 deletions src/Common/tests/System/Xml/ModuleCore/ModuleCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{3CF0CC76-4CE0-460A-BA37-657CFED39AB0}</ProjectGuid>
</PropertyGroup>
Expand All @@ -25,5 +23,4 @@
<Compile Include="XunitRunner.cs" />
<Compile Include="XunitTestCase.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
5 changes: 1 addition & 4 deletions src/Common/tests/System/Xml/XmlCoreTest/XmlCoreTest.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{89701565-F68B-46D9-BD78-95B0F052C50B}</ProjectGuid>
<AssemblyName>XmlCoreTest</AssemblyName>
Expand Down Expand Up @@ -30,5 +28,4 @@
<ProjectReference Include="..\ModuleCore\ModuleCore.csproj" />
<ProjectReference Include="..\XmlDiff\XmlDiff.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
5 changes: 1 addition & 4 deletions src/Common/tests/System/Xml/XmlDiff/XmlDiff.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{466D87DF-BDEC-4E6C-BACD-317D79B8EDBE}</ProjectGuid>
<AssemblyName>XmlDiff</AssemblyName>
Expand All @@ -22,5 +20,4 @@
<ItemGroup>
<ProjectReference Include="..\ModuleCore\ModuleCore.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{E2E59C98-998F-9965-991D-99411166AF6F}</ProjectGuid>
<ShouldWriteSigningRequired>false</ShouldWriteSigningRequired>
Expand All @@ -13,5 +11,4 @@
<Compile Include="CoreFx.Private.TestUtilities.cs" />
<ReferenceFromRuntime Include="xunit.core" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>CoreFx.Private.TestUtilities</AssemblyName>
<ProjectGuid>{EBDB0247-CA43-4226-B7A1-8FEF21061D09}</ProjectGuid>
Expand Down Expand Up @@ -133,5 +131,4 @@
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{5E0DB390-A45E-41BE-8304-B840327FE597}</ProjectGuid>
</PropertyGroup>
Expand All @@ -13,5 +11,4 @@
<Compile Include="AssertExtensionTests.cs" />
<Compile Include="TheoryExtensionTests.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
14 changes: 14 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), dir.props))\dir.props" />
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<NoWarn>CS3021;$(NoWarn)</NoWarn>
<RestoreOutputPath>$(MSBuildThisFileDirectory)\System.Runtime\ref\</RestoreOutputPath>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this going to System.Runtime\ref?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a remnant of changes I brought in from Jose's original changeset - the location pointed to here needs a project.assets.json file, which I also added in this change. I'm not married to that particular location

Copy link
Member

Choose a reason for hiding this comment

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

This is wrong, I had it like this as part of my changes only when I was iterating on some changes and wanted to verify that stuff was being restored correctly. This should be removed.

<IsSDKProject>true</IsSDKProject>
</PropertyGroup>
<PropertyGroup>
<CSharpCoreTargetsPath>$(MSBuildExtensionsPath32)\Roslyn\Microsoft.CSharp.Core.targets</CSharpCoreTargetsPath>
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to explicitly set these here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also a remnant I took from Jose's original changeset - I haven't tried running a build without it yet.

<VisualBasicCoreTargetsPath>$(MSBuildExtensionsPath32)\Roslyn\Microsoft.VisualBasic.Core.targets</VisualBasicCoreTargetsPath>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project InitialTargets="AddSkipGetTargetFrameworkToProjectReferences">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), dir.targets))\dir.targets" />
Copy link
Member

Choose a reason for hiding this comment

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

What are these targets for?

Copy link
Member

Choose a reason for hiding this comment

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

This is just what imports the parent directory's dir.targets. We used to have this per project, and we now have it only once on the common file.

Copy link
Member

Choose a reason for hiding this comment

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

Should we instead of import dir.targets, rename dir.targets to Directory.Build.Targets?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would be fine with that, though it would probably confuse some devs at first

Copy link

Choose a reason for hiding this comment

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

Directory.Build.Targets is a new feature of msbuild that some repos under dotnet/aspnet have started to use already:
https://github.com/search?q=org:dotnet+filename:directory.build.targets
https://github.com/search?q=org:aspnet+filename:directory.build.targets

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think I should rename all dir.props/dir.targets to Directory.Build.props/targets? @joperezr is there documentation on how SDK projects automatically find files named as such? Will there be collisions if multiple files share that name across different parts of the directory tree?

Copy link
Member

Choose a reason for hiding this comment

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

is there documentation on how SDK projects automatically find files named as such?

Check out https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build

Copy link
Contributor

Choose a reason for hiding this comment

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

dir.props and dir.targets are maltilayered in many repos (they are present at multiple directory levels and recursively each one includes higher level projects). Directory.Build.props/.targets are included once - after first include higher level ones will be skipped. This may cause some problems unless recursive include logic from dirs.props is applied to Directory.Build.* files as well.

Copy link
Member

Choose a reason for hiding this comment

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

I expect we will recursively include them if we nest them.

Copy link
Member

@eerhardt eerhardt May 23, 2018

Choose a reason for hiding this comment

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

Yes, this is expected with Directory.Build.*. The first one gets imported, and then if there are parent props/targets files, they need to be explicitly included up the chain. This allows props/target authors to get the ordering right, which is important especially in props files.

We do this in the dotnet/machinelearning repo: https://github.com/dotnet/machinelearning/blob/master/src/Directory.Build.props#L3

<Target Name="_CheckForInvalidConfigurationAndPlatform" />
<Target Name="_CheckForUnsupportedTargetFramework" />
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it is part of your buildtools changes but how are we blocking the import of the csharp targets?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't explicitly done this yet, maybe a change I will have to implement in buildtools.

<Target Name="RunResolvePackageDependencies" />
<Target Name="AddSkipGetTargetFrameworkToProjectReferences" Condition="'@(ProjectReference)' != ''">
<ItemGroup>
<ProjectReference>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
</Target>
</Project>
5 changes: 1 addition & 4 deletions src/Microsoft.CSharp/ref/Microsoft.CSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Must match version supported by frameworks which support 4.0.* inbox.
Can be removed when API is added and this assembly is versioned to 4.1.* -->
Expand All @@ -12,5 +10,4 @@
<ItemGroup>
<Compile Include="Microsoft.CSharp.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
5 changes: 1 addition & 4 deletions src/Microsoft.CSharp/src/Microsoft.CSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{96AA2060-C846-4E56-9509-E8CB9C114C8F}</ProjectGuid>
<AssemblyName>Microsoft.CSharp</AssemblyName>
Expand Down Expand Up @@ -184,5 +182,4 @@
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Threading" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
5 changes: 1 addition & 4 deletions src/Microsoft.CSharp/tests/Microsoft.CSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{82B54697-0251-47A1-8546-FC507D0F3B08}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -40,5 +38,4 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.Diagnostics.Tracing.EventSource</AssemblyName>
<ProjectGuid>{0CAF38F5-C7E7-46F2-8F39-C5D57492FF7F}</ProjectGuid>
Expand All @@ -23,5 +21,4 @@
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{0657A043-0AEE-445E-9BE4-0B3A9D80318F}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_ETLEVENTS</DefineConstants>
Expand Down Expand Up @@ -40,5 +38,4 @@
<Compile Include="$(SDTTestDir)\CustomEventSources\UseAbstractEventSource.cs" />
<Compile Include="$(SDTTestDir)\CustomEventSources\UseInterfaceEventSource.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
5 changes: 1 addition & 4 deletions src/Microsoft.VisualBasic/ref/Microsoft.VisualBasic.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<ProjectGuid>{83AAB173-0A5E-4F7A-A1B4-D847F6D49B5F}</ProjectGuid>
Expand All @@ -10,5 +8,4 @@
<ItemGroup>
<Compile Include="Microsoft.VisualBasic.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{325260D6-D5DD-4E06-9DA2-9AF2AD9DE8C8}</ProjectGuid>
</PropertyGroup>
Expand All @@ -18,5 +16,4 @@
<ItemGroup>
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{4DB14BDE-4B2C-4F08-9FE9-789BFE78F3ED}</ProjectGuid>
</PropertyGroup>
Expand All @@ -14,5 +12,4 @@
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{8FFE99C0-22F8-4462-B839-970EAC1B3472}</ProjectGuid>
<RootNamespace>Microsoft.Win32.Primitives</RootNamespace>
Expand Down Expand Up @@ -41,5 +39,4 @@
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{3B17C130-FF2C-4B41-82C6-FADF4ED7FDA0}</ProjectGuid>
</PropertyGroup>
Expand All @@ -15,5 +13,4 @@
<ItemGroup>
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Loading