diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Directory.Build.props | 6 | ||||
-rw-r--r-- | src/Directory.Build.targets | 43 |
2 files changed, 44 insertions, 5 deletions
diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9eacf3f5..35ef739b 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props | |||
@@ -10,7 +10,7 @@ | |||
10 | <EnableSourceLink Condition=" '$(NCrunch)' == '1' ">false</EnableSourceLink> | 10 | <EnableSourceLink Condition=" '$(NCrunch)' == '1' ">false</EnableSourceLink> |
11 | 11 | ||
12 | <ProjectName Condition=" '$(ProjectName)' == '' ">$(MSBuildProjectName)</ProjectName> | 12 | <ProjectName Condition=" '$(ProjectName)' == '' ">$(MSBuildProjectName)</ProjectName> |
13 | <BaseOutputPath>$(MSBuildThisFileDirectory)..\build\</BaseOutputPath> | 13 | <BaseOutputPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\))</BaseOutputPath> |
14 | <BaseIntermediateOutputPath>$(BaseOutputPath)obj\$(ProjectName)\</BaseIntermediateOutputPath> | 14 | <BaseIntermediateOutputPath>$(BaseOutputPath)obj\$(ProjectName)\</BaseIntermediateOutputPath> |
15 | <OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath> | 15 | <OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath> |
16 | 16 | ||
@@ -20,10 +20,6 @@ | |||
20 | <Product>WiX Toolset</Product> | 20 | <Product>WiX Toolset</Product> |
21 | </PropertyGroup> | 21 | </PropertyGroup> |
22 | 22 | ||
23 | <PropertyGroup> | ||
24 | <WixToolsetRootFolder>$(MSBuildThisFileDirectory)..\..\</WixToolsetRootFolder> | ||
25 | </PropertyGroup> | ||
26 | |||
27 | <Import Project="Cpp.Build.props" Condition=" '$(MSBuildProjectExtension)'=='.vcxproj' " /> | 23 | <Import Project="Cpp.Build.props" Condition=" '$(MSBuildProjectExtension)'=='.vcxproj' " /> |
28 | <Import Project="Custom.Build.props" Condition=" Exists('Custom.Build.props') " /> | 24 | <Import Project="Custom.Build.props" Condition=" Exists('Custom.Build.props') " /> |
29 | </Project> | 25 | </Project> |
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..48629385 --- /dev/null +++ b/src/Directory.Build.targets | |||
@@ -0,0 +1,43 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- | ||
3 | Replace PackageReferences with ProjectReferences when the projects can be found in .sln. | ||
4 | See the original here: https://github.com/dotnet/sdk/issues/1151#issuecomment-385133284 | ||
5 | --> | ||
6 | <Project> | ||
7 | <PropertyGroup> | ||
8 | <ReplacePackageReferences>true</ReplacePackageReferences> | ||
9 | <TheSolutionPath Condition=" '$(NCrunch)'=='' ">$(SolutionPath)</TheSolutionPath> | ||
10 | <TheSolutionPath Condition=" '$(NCrunch)'=='1' ">$(NCrunchOriginalSolutionPath)</TheSolutionPath> | ||
11 | </PropertyGroup> | ||
12 | |||
13 | <Choose> | ||
14 | <When Condition="$(ReplacePackageReferences) AND '$(TheSolutionPath)' != '' AND '$(TheSolutionPath)' != '*undefined*' AND Exists('$(TheSolutionPath)')"> | ||
15 | |||
16 | <PropertyGroup> | ||
17 | <SolutionFileContent>$([System.IO.File]::ReadAllText($(TheSolutionPath)))</SolutionFileContent> | ||
18 | <SmartSolutionDir>$([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) ))</SmartSolutionDir> | ||
19 | <RegexPattern>(?<="[PackageName]", ")(.*)(?=", ")</RegexPattern> | ||
20 | </PropertyGroup> | ||
21 | |||
22 | <ItemGroup> | ||
23 | <!-- Keep the identity of the PackageReference --> | ||
24 | <SmartPackageReference Include="@(PackageReference)"> | ||
25 | <PackageName>%(Identity)</PackageName> | ||
26 | <InSolution>$(SolutionFileContent.Contains('\%(Identity).csproj'))</InSolution> | ||
27 | </SmartPackageReference> | ||
28 | |||
29 | <!-- Filter them by mapping them to another ItemGroup using the WithMetadataValue item function --> | ||
30 | <PackageInSolution Include="@(SmartPackageReference->WithMetadataValue('InSolution', True))"> | ||
31 | <Pattern>$(RegexPattern.Replace('[PackageName]','%(PackageName)') )</Pattern> | ||
32 | <SmartPath>$([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)'))</SmartPath> | ||
33 | </PackageInSolution> | ||
34 | |||
35 | <ProjectReference Include="@(PackageInSolution->'$(SmartSolutionDir)\%(SmartPath)' )"/> | ||
36 | |||
37 | <!-- Remove the package references that are now referenced as projects --> | ||
38 | <PackageReference Remove="@(PackageInSolution->'%(PackageName)' )"/> | ||
39 | </ItemGroup> | ||
40 | |||
41 | </When> | ||
42 | </Choose> | ||
43 | </Project> | ||