Skip to content
Closed
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
6 changes: 6 additions & 0 deletions src/wix/WixToolset.Sdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
@@ -12,6 +12,12 @@
<EnableDefaultItems Condition=" '$(EnableDefaultItems)' == '' ">true</EnableDefaultItems>
<EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">true</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems Condition=" '$(EnableDefaultEmbeddedResourceItems)' == '' ">true</EnableDefaultEmbeddedResourceItems>

<!--
Import UseArtifactsOutputPath.props after Directory.Build.props, where UseArtifactsOutput and similar settings will be configured by the consumer.
See https://github.com/dotnet/sdk/blob/23e2ba847d79562b972dbf54eca3f87c3044d925/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props#L41
-->
<CustomAfterDirectoryBuildProps>$(CustomAfterDirectoryBuildProps);$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory), '..\tools\WixToolset.UseArtifactsOutputPath.props'))</CustomAfterDirectoryBuildProps>
</PropertyGroup>

<Import Project="$(WixPropsPath)" Condition=" '$(WixPropsPath)' != '' and Exists('$(WixPropsPath)')" />
3 changes: 3 additions & 0 deletions src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -17,8 +17,11 @@

<ItemGroup>
<Content Include="build\$(MSBuildThisFileName).targets" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\WixToolset.DefaultArtifactsPath.props" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\WixToolset.DefaultOutputPaths.targets" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\WixToolset.Signing.props" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\WixToolset.Signing.targets" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\WixToolset.UseArtifactsOutputPath.props" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\wix.props" CopyToOutputDirectory="PreserveNewest" />
<Content Include="tools\wix.targets" CopyToOutputDirectory="PreserveNewest" />
<Content Include="Sdk\Sdk.props" CopyToOutputDirectory="PreserveNewest" />
38 changes: 38 additions & 0 deletions src/wix/WixToolset.Sdk/tools/WixToolset.DefaultArtifactsPath.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Ported from: https://github.com/dotnet/sdk/blob/23e2ba847d79562b972dbf54eca3f87c3044d925/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultArtifactsPath.props
Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
-->
<Project>

<!-- This .props file may be imported either from Sdk.props or from Microsoft.NET.DefaultOutputPaths.targets, depending
on whether artifacts output properties were set in Directory.Build.props or not.

Set a property to indicate it was imported, so we can avoid a duplicate import. -->
<PropertyGroup>
<_DefaultArtifactsPathPropsImported>true</_DefaultArtifactsPathPropsImported>
</PropertyGroup>

<!-- Setting ArtifactsPath automatically opts in to the artifacts output format -->
<PropertyGroup Condition="'$(ArtifactsPath)' != '' And '$(UsingMicrosoftArtifactsSdk)' != 'true'">
<UseArtifactsOutput Condition="'$(UseArtifactsOutput)' == ''">true</UseArtifactsOutput>
<IncludeProjectNameInArtifactsPaths Condition="'$(IncludeProjectNameInArtifactsPaths)' == ''">true</IncludeProjectNameInArtifactsPaths>
<_ArtifactsPathLocationType>ExplicitlySpecified</_ArtifactsPathLocationType>
</PropertyGroup>

<!-- Set up base output folders if UseArtifactsOutput is set. The .NET SDK implementatino uses _DirectoryBuildPropsBasePath,
but this implementation uses DirectoryBuildPropsPath instead to avoid depending on a private property that may change in the future. -->
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPath)' == '' And '$(DirectoryBuildPropsPath)' != ''">
<!-- Default ArtifactsPath to be in the directory where Directory.Build.props is found
Note that we do not append a backslash to the ArtifactsPath as we do with most paths, because it may be a global property passed in on the command-line which we can't easily change -->
<ArtifactsPath>$([System.IO.Path]::GetDirectoryName('$(DirectoryBuildPropsPath)'))\artifacts</ArtifactsPath>
<IncludeProjectNameInArtifactsPaths Condition="'$(IncludeProjectNameInArtifactsPaths)' == ''">true</IncludeProjectNameInArtifactsPaths>
<_ArtifactsPathLocationType>DirectoryBuildPropsFolder</_ArtifactsPathLocationType>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPath)' == ''">
<!-- If there was no Directory.Build.props file, then put the artifacts path in the project folder -->
<ArtifactsPath>$(MSBuildProjectDirectory)\artifacts</ArtifactsPath>
<_ArtifactsPathLocationType>ProjectFolder</_ArtifactsPathLocationType>
</PropertyGroup>
</Project>
89 changes: 89 additions & 0 deletions src/wix/WixToolset.Sdk/tools/WixToolset.DefaultOutputPaths.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Ported from: https://github.com/dotnet/sdk/blob/23e2ba847d79562b972dbf54eca3f87c3044d925/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets
Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Import .props file to set ArtifactsPath if it wasn't already imported from Sdk.props (this is for the case when artifacts
properties are set in the project file instead of Directory.Build.props) -->
<Import Project="$(MSBuildThisFileDirectory)WixToolset.DefaultArtifactsPath.props"
Condition="'$(_DefaultArtifactsPathPropsImported)' != 'true'"/>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<ArtifactsProjectName Condition="'$(ArtifactsProjectName)' == ''">$(MSBuildProjectName)</ArtifactsProjectName>

<ArtifactsBinOutputName Condition="'$(ArtifactsBinOutputName)' == ''">bin</ArtifactsBinOutputName>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPivots)' == ''">
<!-- ArtifactsPivots will make the subdirectory within "bin" or "obj" become "debug" or "debug_win-x86" based on the configuration and platform. -->
<ArtifactsPivots>$(Configuration.ToLowerInvariant())</ArtifactsPivots>

<!-- Include the platform in the artifacts path if it is explicitly set. Prefix with "win-" to make it consistent with .NET runtime identifiers. -->
<ArtifactsPivots Condition="'$(Platform)' != ''">$(ArtifactsPivots)_win-$(Platform.ToLowerInvariant())</ArtifactsPivots>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(IncludeProjectNameInArtifactsPaths)' == 'true'">
<!-- Set artifacts paths when project name should be included in the path -->
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">$(ArtifactsPath)\$(ArtifactsBinOutputName)\$(ArtifactsProjectName)\</BaseOutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">$(ArtifactsPath)\obj\$(ArtifactsProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(IncludeProjectNameInArtifactsPaths)' != 'true'">
<!-- Set artifacts paths when project name should not be included in the path -->
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">$(ArtifactsPath)\$(ArtifactsBinOutputName)\</BaseOutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">$(ArtifactsPath)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<OutputPath Condition="'$(OutputPath)' == ''">$(BaseOutputPath)$(ArtifactsPivots)\</OutputPath>
<IntermediateOutputPath Condition=" $(IntermediateOutputPath) == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">$(BaseIntermediateOutputPath)$(ArtifactsPivots)\</IntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' != 'true'">
<!-- Ensure BaseOutputPath for Microsoft.Common.targets -->
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">bin\</BaseOutputPath>
<BaseOutputPath Condition="!HasTrailingSlash('$(BaseOutputPath)')">$(BaseOutputPath)\</BaseOutputPath>
</PropertyGroup>

<!-- Configure default item exclusions -->

<PropertyGroup Condition="'$(UseArtifactsOutput)' != 'true'">
<DefaultItemExcludes Condition=" '$(BaseOutputPath)' != '' ">$(DefaultItemExcludes);$(BaseOutputPath)**</DefaultItemExcludes>
<DefaultItemExcludes Condition=" '$(BaseIntermediateOutputPath)' != '' ">$(DefaultItemExcludes);$(BaseIntermediateOutputPath)**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<DefaultItemExcludes>$(DefaultItemExcludes);$(ArtifactsPath)/**</DefaultItemExcludes>
<!-- Exclude bin and obj folders to avoid issues with projects that switch to using artifacts output format -->
<DefaultItemExcludes>$(DefaultItemExcludes);bin/**;obj/**</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup>
<DefaultExcludesInProjectFolder>$(DefaultItemExcludesInProjectFolder);**/.*/**</DefaultExcludesInProjectFolder>
</PropertyGroup>

<Target Name="_CheckForUnsupportedArtifactsPath"
BeforeTargets="ResolveReferences">

<!-- Generate an error if ArtifactsPath or UseArtifactsOutput are set in the project file.

We generate an error because if they are set in the project file, it is too late to change the intermediate output path,
and because it would be confusing to set the property in the project file and have the artifacts path depend on whether
there happened to be a Directory.Build.props file defined.
-->

<Error Condition="'$(UseArtifactsOutput)' == 'true' and '$(_ArtifactsPathSetEarly)' != 'true'"
File="$(MSBuildProjectFile)"
Code="WIX9000"
Text="The ArtifactsPath and UseArtifactsOutput properties cannot be set in a project file, due to MSBuild ordering constraints. They must be set in a Directory.Build.props file or from the command line. See https://aka.ms/netsdk1199 for more information." />

<Error Condition="'$(_ArtifactsPathLocationType)' == 'ProjectFolder'"
File="$(MSBuildProjectFile)"
Code="WIX9001"
Text="If UseArtifactsPath is set to true and ArtifactsPath is not set, there must be a Directory.Build.props file in order to determine where the artifacts folder should be located." />

</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Ported from: https://github.com/dotnet/sdk/blob/23e2ba847d79562b972dbf54eca3f87c3044d925/src/Tasks/Microsoft.NET.Build.Tasks/sdk/UseArtifactsOutputPath.props
Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- If ArtifactsPath or UseArtifactsOutput are set, then import .props to set ArtifactsPath here, so that BaseIntermediateOutputPath can be
set in the ArtifactsPath.
If the .props file is not imported here, it will be imported from DefaultOutputPaths.targets, so that artifacts output
properties can be set directly in the project file too (only in that case they won't affect the intermediate output). -->
<Import Project="$(MSBuildThisFileDirectory)WixToolset.DefaultArtifactsPath.props"
Condition="'$(UseArtifactsOutput)' == 'true' Or '$(ArtifactsPath)' != ''"/>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<UseArtifactsIntermediateOutput Condition="'$(UseArtifactsIntermediateOutput)' == ''">true</UseArtifactsIntermediateOutput>
<ArtifactsProjectName Condition="'$(ArtifactsProjectName)' == ''">$(MSBuildProjectName)</ArtifactsProjectName>
</PropertyGroup>

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">
<BaseIntermediateOutputPath Condition="'$(IncludeProjectNameInArtifactsPaths)' == 'true'">$(ArtifactsPath)\obj\$(ArtifactsProjectName)\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(ArtifactsPath)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>

<!-- Record whether ArtifactsPath / UseArtifactsOutput was set at this point in evaluation. We will generate an error if these properties are set
after this point (ie in the project file). -->
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
<_ArtifactsPathSetEarly>true</_ArtifactsPathSetEarly>
</PropertyGroup>
</Project>
12 changes: 2 additions & 10 deletions src/wix/WixToolset.Sdk/tools/wix.targets
Original file line number Diff line number Diff line change
@@ -57,16 +57,14 @@
***********************************************************************************************
-->

<Import Project="WixToolset.DefaultOutputPaths.targets" />

<PropertyGroup>
<DefaultProjectTypeGuid Condition=" '$(DefaultProjectTypeGuid)' == '' ">{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}</DefaultProjectTypeGuid>
<DefaultLanguageSourceExtension>.wxs</DefaultLanguageSourceExtension>
<Language>wix</Language>
<TargetRuntime>wix</TargetRuntime>

<!-- Ensure BaseOutputPath for Microsoft.Common.targets -->
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">bin\</BaseOutputPath>
<BaseOutputPath Condition="!HasTrailingSlash('$(BaseOutputPath)')">$(BaseOutputPath)\</BaseOutputPath>

<!-- Use OutputName to set the AssemblyName for Microsoft.Common.targets -->
<OutputName Condition=" '$(OutputName)'=='' ">$(MSBuildProjectName)</OutputName>
<AssemblyName>$(OutputName)</AssemblyName>
@@ -945,12 +943,6 @@
<!-- Extension point: Define CustomAfterWixTargets to a .targets file that you want to include after this file. -->
<Import Project="$(CustomAfterWixTargets)" Condition=" '$(CustomAfterWixTargets)' != '' and Exists('$(CustomAfterWixTargets)')" />

<PropertyGroup>
<DefaultItemExcludes Condition=" '$(BaseOutputPath)' != '' ">$(DefaultItemExcludes);$(BaseOutputPath)**</DefaultItemExcludes>
<DefaultItemExcludes Condition=" '$(BaseIntermediateOutputPath)' != '' ">$(DefaultItemExcludes);$(BaseIntermediateOutputPath)**</DefaultItemExcludes>
<DefaultExcludesInProjectFolder>$(DefaultItemExcludesInProjectFolder);**/.*/**</DefaultExcludesInProjectFolder>
</PropertyGroup>

<ImportGroup>
<Import Project="$(MSBuildUserExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter\*" Condition="'$(ImportUserLocationsByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildUserExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter')" />
<Import Project="$(MSBuildExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter\*" Condition="'$(ImportByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter')" />
176 changes: 176 additions & 0 deletions src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
Original file line number Diff line number Diff line change
@@ -852,6 +852,182 @@ public void CanBuildPackageWithComma(BuildSystem buildSystem)
}
}

[Theory]
[InlineData(BuildSystem.DotNetCoreSdk)]
[InlineData(BuildSystem.MSBuild)]
[InlineData(BuildSystem.MSBuild64)]
public void CanBuildPackageWithUseArtifactsOutput(BuildSystem buildSystem)
{
var expectedOutputFiles = new[]
{
@"artifacts\bin\MsiPackage\release_win-x86\en-US\cab1.cab",
@"artifacts\bin\MsiPackage\release_win-x86\en-US\MsiPackage.msi",
@"artifacts\bin\MsiPackage\release_win-x86\en-US\MsiPackage.wixpdb",
@"artifacts\obj\MsiPackage\release_win-x86\en-US\cab1.cab",
@"artifacts\obj\MsiPackage\release_win-x86\en-US\MsiPackage.msi",
@"artifacts\obj\MsiPackage\release_win-x86\en-US\MsiPackage.wixpdb",
};

var sourceFolder = TestData.Get(@"TestData", "SimpleMsiPackage");

using (var fs = new TestDataFolderFileSystem())
{
fs.Initialize(sourceFolder);
var baseFolder = fs.BaseFolder;
var artifactsFolder = Path.Combine(baseFolder, "artifacts");
var projectPath = Path.Combine(baseFolder, @"MsiPackage\MsiPackage.wixproj");

var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
{
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
"-p:SuppressValidation=true",
"-p:UseArtifactsOutput=true"
});
result.AssertSuccess();

var paths = Directory.EnumerateFiles(artifactsFolder, @"*.*", SearchOption.AllDirectories)
.Where(s =>
// ignore bind tracking files and MSBuild internals
!s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) &&
!s.EndsWith(".cache", StringComparison.OrdinalIgnoreCase))
.Select(s => s.Substring(baseFolder.Length + 1))
.OrderBy(s => s)
.ToArray();
WixAssert.CompareLineByLine(expectedOutputFiles, paths);
}
}

[Theory]
[InlineData(BuildSystem.DotNetCoreSdk)]
[InlineData(BuildSystem.MSBuild)]
[InlineData(BuildSystem.MSBuild64)]
public void CanBuildPackageWithExplicitArtifactsPath(BuildSystem buildSystem)
{
var expectedOutputFiles = new[]
{
@"artifacts\subdir\bin\MsiPackage\release_win-x86\en-US\cab1.cab",
@"artifacts\subdir\bin\MsiPackage\release_win-x86\en-US\MsiPackage.msi",
@"artifacts\subdir\bin\MsiPackage\release_win-x86\en-US\MsiPackage.wixpdb",
@"artifacts\subdir\obj\MsiPackage\release_win-x86\en-US\cab1.cab",
@"artifacts\subdir\obj\MsiPackage\release_win-x86\en-US\MsiPackage.msi",
@"artifacts\subdir\obj\MsiPackage\release_win-x86\en-US\MsiPackage.wixpdb",
};

var sourceFolder = TestData.Get(@"TestData", "SimpleMsiPackage");

using (var fs = new TestDataFolderFileSystem())
{
fs.Initialize(sourceFolder);
var baseFolder = fs.BaseFolder;
var artifactsFolder = Path.Combine(baseFolder, @"artifacts\subdir");
var projectPath = Path.Combine(baseFolder, @"MsiPackage\MsiPackage.wixproj");

var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
{
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
"-p:SuppressValidation=true",
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "ArtifactsPath", Path.Combine(baseFolder, "artifacts", "subdir"))
});
result.AssertSuccess();

var paths = Directory.EnumerateFiles(artifactsFolder, @"*.*", SearchOption.AllDirectories)
.Where(s =>
// ignore bind tracking files and MSBuild internals
!s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) &&
!s.EndsWith(".cache", StringComparison.OrdinalIgnoreCase))
.Select(s => s.Substring(baseFolder.Length + 1))
.OrderBy(s => s)
.ToArray();
WixAssert.CompareLineByLine(expectedOutputFiles, paths);
}
}

[Theory]
[InlineData(BuildSystem.DotNetCoreSdk)]
[InlineData(BuildSystem.MSBuild)]
[InlineData(BuildSystem.MSBuild64)]
public void CanBuildBundleWithUseArtifactsOutput(BuildSystem buildSystem)
{
var expectedOutputFiles = new[]
{
@"artifacts\bin\SimpleBundle\release_win-x86\SimpleBundle.exe",
@"artifacts\bin\SimpleBundle\release_win-x86\SimpleBundle.wixpdb",
@"artifacts\obj\SimpleBundle\release_win-x86\SimpleBundle.exe",
@"artifacts\obj\SimpleBundle\release_win-x86\SimpleBundle.wixpdb",
};

var sourceFolder = TestData.Get(@"TestData", "SimpleMsiPackage");

using (var fs = new TestDataFolderFileSystem())
{
fs.Initialize(sourceFolder);
var baseFolder = fs.BaseFolder;
var artifactsFolder = Path.Combine(baseFolder, "artifacts");
var projectPath = Path.Combine(baseFolder, @"SimpleBundle\SimpleBundle.wixproj");

var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
{
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
"-p:SuppressValidation=true",
"-p:UseArtifactsOutput=true"
});
result.AssertSuccess();

var paths = Directory.EnumerateFiles(artifactsFolder, @"*.*", SearchOption.AllDirectories)
.Where(s =>
// ignore bind tracking files and MSBuild internals
!s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) &&
!s.EndsWith(".cache", StringComparison.OrdinalIgnoreCase))
.Select(s => s.Substring(baseFolder.Length + 1))
.OrderBy(s => s)
.ToArray();
WixAssert.CompareLineByLine(expectedOutputFiles, paths);
}
}

[Theory]
[InlineData(BuildSystem.DotNetCoreSdk)]
[InlineData(BuildSystem.MSBuild)]
[InlineData(BuildSystem.MSBuild64)]
public void CanBuildBundleWithExplicitArtifactsPath(BuildSystem buildSystem)
{
var expectedOutputFiles = new[]
{
@"artifacts\subdir\bin\SimpleBundle\release_win-x86\SimpleBundle.exe",
@"artifacts\subdir\bin\SimpleBundle\release_win-x86\SimpleBundle.wixpdb",
@"artifacts\subdir\obj\SimpleBundle\release_win-x86\SimpleBundle.exe",
@"artifacts\subdir\obj\SimpleBundle\release_win-x86\SimpleBundle.wixpdb",
};

var sourceFolder = TestData.Get(@"TestData", "SimpleMsiPackage");

using (var fs = new TestDataFolderFileSystem())
{
fs.Initialize(sourceFolder);
var baseFolder = fs.BaseFolder;
var artifactsFolder = Path.Combine(baseFolder, @"artifacts\subdir");
var projectPath = Path.Combine(baseFolder, @"SimpleBundle\SimpleBundle.wixproj");

var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
{
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
"-p:SuppressValidation=true",
MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "ArtifactsPath", Path.Combine(baseFolder, "artifacts", "subdir"))
});
result.AssertSuccess();

var paths = Directory.EnumerateFiles(artifactsFolder, @"*.*", SearchOption.AllDirectories)
.Where(s =>
// ignore bind tracking files and MSBuild internals
!s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) &&
!s.EndsWith(".cache", StringComparison.OrdinalIgnoreCase))
.Select(s => s.Substring(baseFolder.Length + 1))
.OrderBy(s => s)
.ToArray();
WixAssert.CompareLineByLine(expectedOutputFiles, paths);
}
}

[Theory(Skip = "Depends on creating broken publish which is not supported at this time")]
[InlineData(BuildSystem.DotNetCoreSdk)]
[InlineData(BuildSystem.MSBuild)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->

<!-- This file acts as the reference point for the artifacts directory if -p:UseArtifactsOutput=true is passed to the build -->
<Project>
</Project>
Original file line number Diff line number Diff line change
@@ -12,21 +12,21 @@

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformName>$(Platform)</PlatformName>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<OutputPath Condition="'$(UseArtifactsOutput)' != 'true'">bin\$(Platform)\$(Configuration)\</OutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformName>$(Platform)</PlatformName>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<OutputPath Condition="'$(UseArtifactsOutput)' != 'true'">bin\$(Platform)\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformName>$(Platform)</PlatformName>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<OutputPath Condition="'$(UseArtifactsOutput)' != 'true'">bin\$(Platform)\$(Configuration)\</OutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformName>$(Platform)</PlatformName>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<OutputPath Condition="'$(UseArtifactsOutput)' != 'true'">bin\$(Platform)\$(Configuration)\</OutputPath>
</PropertyGroup>

<ItemGroup>