This repository has been archived by the owner on Apr 2, 2020. It is now read-only.
forked from Protobuild/Protobuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Exclude" attribute support to Compile tag (Protobuild#258)
* Add "Exclude" attribute support to Compile tag According to the following documents: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-exclude-files-from-the-build https://docs.microsoft.com/en-us/dotnet/core/tools/csproj The Compile & Content tags did support glob patterns, and "exclude" is an essential complement to "include". This is very useful for porting existing Unity modules / plugins to Protobuild (for example exclude those files inside the Editor folder while using globs). * Build Protobuild and add tests
- Loading branch information
Showing
24 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Protobuild.FunctionalTests/ExcludeAttributeMissingOnItemsThatDontUseItTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Protobuild.Tests | ||
{ | ||
using System.IO; | ||
using Prototest.Library.Version1; | ||
|
||
public class ExcludeAttributeMissingOnItemsThatDontUseItTest : ProtobuildTest | ||
{ | ||
private readonly IAssert _assert; | ||
|
||
public ExcludeAttributeMissingOnItemsThatDontUseItTest(IAssert assert) : base(assert) | ||
{ | ||
_assert = assert; | ||
} | ||
|
||
public void GenerationIsCorrect() | ||
{ | ||
this.SetupTest("ExcludeAttributeMissingOnItemsThatDontUseIt"); | ||
|
||
this.Generate("Windows"); | ||
|
||
_assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); | ||
_assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); | ||
|
||
var projectContents = this.ReadFile(@"Console\Console.Windows.csproj"); | ||
|
||
_assert.DoesNotContain("Exclude=", projectContents); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Protobuild.FunctionalTests/ExcludeAttributeOnItemsGeneratedCorrectlyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Protobuild.Tests | ||
{ | ||
using System.IO; | ||
using Prototest.Library.Version1; | ||
|
||
public class ExcludeAttributeOnItemsGeneratedCorrectlyTest : ProtobuildTest | ||
{ | ||
private readonly IAssert _assert; | ||
|
||
public ExcludeAttributeOnItemsGeneratedCorrectlyTest(IAssert assert) : base(assert) | ||
{ | ||
_assert = assert; | ||
} | ||
|
||
public void GenerationIsCorrect() | ||
{ | ||
this.SetupTest("ExcludeAttributeOnItemsGeneratedCorrectly"); | ||
|
||
this.Generate("Windows"); | ||
|
||
_assert.True(File.Exists(this.GetPath(@"Module.Windows.sln"))); | ||
_assert.True(File.Exists(this.GetPath(@"Console\Console.Windows.csproj"))); | ||
|
||
var projectContents = this.ReadFile(@"Console\Console.Windows.csproj"); | ||
|
||
_assert.Contains("<Compile Include=\"*\" Exclude=\"Program.cs\" />", projectContents); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Protobuild.FunctionalTests/ExcludeAttributeOnItemsSynchronisedCorrectlyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Protobuild.Tests | ||
{ | ||
using System.IO; | ||
using Prototest.Library.Version1; | ||
|
||
public class ExcludeAttributeOnItemsSynchronisedCorrectlyTest : ProtobuildTest | ||
{ | ||
private readonly IAssert _assert; | ||
|
||
public ExcludeAttributeOnItemsSynchronisedCorrectlyTest(IAssert assert) : base(assert) | ||
{ | ||
_assert = assert; | ||
} | ||
|
||
public void GenerationIsCorrect() | ||
{ | ||
this.SetupTest("ExcludeAttributeOnItemsSynchronisedCorrectly"); | ||
|
||
// Reset the definition back to it's original version for the test. | ||
var original = this.GetPath(@"Build\OriginalProjects\Console.definition"); | ||
var target = this.GetPath(@"Build\Projects\Console.definition"); | ||
File.Copy(original, target, true); | ||
|
||
this.OtherMode("sync", "Windows", purge: false); | ||
|
||
var targetContents = this.ReadFile(@"Build\Projects\Console.definition"); | ||
|
||
try | ||
{ | ||
_assert.Contains("Exclude=\"Program.cs\"", targetContents); | ||
} | ||
finally | ||
{ | ||
// Reset the file back after the test passes so that Git doesn't | ||
// report this file as changed. | ||
File.Copy(original, target, true); | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ild.FunctionalTests/TestData/ExcludeAttributeMissingOnItemsThatDontUseIt/Build/Module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Module> | ||
<Name>Module</Name> | ||
<DefaultAction>resync</DefaultAction> | ||
<GenerateNuGetRepositories>true</GenerateNuGetRepositories> | ||
</Module> |
9 changes: 9 additions & 0 deletions
9
...ts/TestData/ExcludeAttributeMissingOnItemsThatDontUseIt/Build/Projects/Console.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Name="Console" Path="Console" Type="Console"> | ||
<References> | ||
<Reference Include="System" /> | ||
</References> | ||
<Files> | ||
<Compile Include="Test.cs" /> | ||
</Files> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
...d.FunctionalTests/TestData/ExcludeAttributeMissingOnItemsThatDontUseIt/Console/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Console | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
// TODO: Implement console app. | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...build.FunctionalTests/TestData/ExcludeAttributeOnItemsGeneratedCorrectly/Build/Module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Module> | ||
<Name>Module</Name> | ||
<DefaultAction>resync</DefaultAction> | ||
<GenerateNuGetRepositories>true</GenerateNuGetRepositories> | ||
</Module> |
9 changes: 9 additions & 0 deletions
9
...ests/TestData/ExcludeAttributeOnItemsGeneratedCorrectly/Build/Projects/Console.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Name="Console" Path="Console" Type="Console"> | ||
<References> | ||
<Reference Include="System" /> | ||
</References> | ||
<Files> | ||
<Compile Include="*" Exclude="Program.cs" /> | ||
</Files> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
...ild.FunctionalTests/TestData/ExcludeAttributeOnItemsGeneratedCorrectly/Console/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Console | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
// TODO: Implement console app. | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ld.FunctionalTests/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Build/Module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Module> | ||
<Name>Module</Name> | ||
<DefaultAction>resync</DefaultAction> | ||
<GenerateNuGetRepositories>true</GenerateNuGetRepositories> | ||
</Module> |
7 changes: 7 additions & 0 deletions
7
...ta/ExcludeAttributeOnItemsSynchronisedCorrectly/Build/OriginalProjects/Console.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Name="Console" Path="Console" Type="Console"> | ||
<References> | ||
<Reference Include="System" /> | ||
</References> | ||
<Files /> | ||
</Project> |
7 changes: 7 additions & 0 deletions
7
...s/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Build/Projects/Console.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Name="Console" Path="Console" Type="Console"> | ||
<References> | ||
<Reference Include="System" /> | ||
</References> | ||
<Files /> | ||
</Project> |
75 changes: 75 additions & 0 deletions
75
...ests/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Console/Console.Windows.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.0</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{736E6F43-6C6F-2E65-5769-6E646F777343}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Console</RootNamespace> | ||
<AssemblyName>Console</AssemblyName> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<NoWarn></NoWarn> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<TargetFrameworkProfile /> | ||
<LangVersion>6</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
<DebugType>full</DebugType> | ||
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging> | ||
<OutputPath>bin\Windows\AnyCPU\Debug</OutputPath> | ||
<IntermediateOutputPath>obj\Windows\AnyCPU\Debug</IntermediateOutputPath> | ||
<DocumentationFile>bin\Windows\AnyCPU\Debug\Console.xml</DocumentationFile> | ||
<DefineConstants>DEBUG;PLATFORM_WINDOWS</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<Optimize>true</Optimize> | ||
<DebugType>none</DebugType> | ||
<OutputPath>bin\Windows\AnyCPU\Release</OutputPath> | ||
<IntermediateOutputPath>obj\Windows\AnyCPU\Release</IntermediateOutputPath> | ||
<DocumentationFile>bin\Windows\AnyCPU\Release\Console.xml</DocumentationFile> | ||
<DefineConstants>PLATFORM_WINDOWS</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="*" Exclude="Program.cs" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<_PostBuildHookTimestamp>@(IntermediateAssembly->'%(FullPath).timestamp')</_PostBuildHookTimestamp> | ||
<_PostBuildHookHostPlatform>$(Platform)</_PostBuildHookHostPlatform> | ||
</PropertyGroup> | ||
<Target Name="PostBuildHooks" Inputs="@(IntermediateAssembly);@(ReferencePath)" Outputs="@(IntermediateAssembly);$(_PostBuildHookTimestamp)" AfterTargets="CoreCompile" BeforeTargets="AfterCompile"> | ||
<Touch Files="$(_PostBuildHookTimestamp)" AlwaysCreate="True" /> | ||
</Target> | ||
<ItemGroup /> | ||
<ItemGroup /> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
....FunctionalTests/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Console/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Console | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
// TODO: Implement console app. | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
....FunctionalTests/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Module.Windows.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.22609.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console.Windows", "Console\Console.Windows.csproj", "{736E6F43-6C6F-2E65-5769-6E646F777343}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{736E6F43-6C6F-2E65-5769-6E646F777343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{736E6F43-6C6F-2E65-5769-6E646F777343}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{736E6F43-6C6F-2E65-5769-6E646F777343}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{736E6F43-6C6F-2E65-5769-6E646F777343}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+43 Bytes
...ionalTests/TestData/ExcludeAttributeOnItemsSynchronisedCorrectly/Module.Windows.speccache
Binary file not shown.
Binary file modified
BIN
+14 Bytes
(100%)
Protobuild.Internal/BuildResources/GenerateProject.CPlusPlus.MonoDevelop.xslt.lzma
Binary file not shown.
Binary file modified
BIN
+22 Bytes
(100%)
Protobuild.Internal/BuildResources/GenerateProject.CPlusPlus.VisualStudio.xslt.lzma
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+55 Bytes
(100%)
Protobuild.Internal/BuildResources/GenerateProject.CSharp.xslt.lzma
Binary file not shown.
Binary file modified
BIN
+17 Bytes
(100%)
Protobuild.Internal/BuildResources/GenerationFunctions.cs-msbuild-hack.lzma
Binary file not shown.
Binary file not shown.
Binary file not shown.