[xharness] Disable default inclusion behavior for the introspection .NET tests. (#9137)
It gets too annoying to keep track of which files are where with the project cloning we're doing, if files are implicitly included.
This commit is contained in:
Родитель
7d47d8742d
Коммит
f9fbf56544
|
@ -12,6 +12,7 @@
|
|||
<AssetTargetFallback>xamarinios10;$(AssetTargetFallback)</AssetTargetFallback>
|
||||
<!-- This is needed because the packages/ directory might be in the same folder as this project file, and some some packages might have C# files, which would then automatically be included -->
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);packages/**;</DefaultItemExcludes>
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -33,6 +34,18 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="iOSApiCtorInitTest.cs" />
|
||||
<Compile Include="iOSApiFieldTest.cs" />
|
||||
<Compile Include="iOSApiSelectorTest.cs" />
|
||||
<Compile Include="iOSApiSignatureTest.cs" />
|
||||
<Compile Include="iOSApiProtocolTest.cs" />
|
||||
<Compile Include="iOSApiWeakPropertyTest.cs" />
|
||||
<Compile Include="iOSApiPInvokeTest.cs" />
|
||||
<Compile Include="iOSApiClassPtrTest.cs" />
|
||||
<Compile Include="iOSApiTypoTest.cs" />
|
||||
<Compile Include="iOSCoreImageFiltersTest.cs" />
|
||||
<Compile Include="..\ApiBaseTest.cs">
|
||||
<Link>ApiBaseTest.cs</Link>
|
||||
</Compile>
|
||||
|
@ -103,6 +116,26 @@
|
|||
<Link>ApiTypeTest.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist">
|
||||
<LogicalName>Info.plist</LogicalName>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="LaunchScreen.storyboard" Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\Contents.json" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\Icon-app-60%403x.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-57.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-57%402x.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-60%402x.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-72.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-72%402x.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-76.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
|
||||
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="..\xamarin1.png">
|
||||
<Link>xamarin1.png</Link>
|
||||
|
|
|
@ -95,50 +95,52 @@ namespace Microsoft.DotNet.XHarness.iOS.Shared {
|
|||
doc.ResolveAllPaths (original_path);
|
||||
|
||||
if (doc.IsDotNetProject ()) {
|
||||
// Many types of files below the csproj directory are included by default,
|
||||
// which means that we have to include them manually in the cloned csproj,
|
||||
// because the cloned project is stored in a very different directory.
|
||||
var test_dir = System.IO.Path.GetDirectoryName (original_path);
|
||||
if (doc.GetEnableDefaultItems () != false) {
|
||||
// Many types of files below the csproj directory are included by default,
|
||||
// which means that we have to include them manually in the cloned csproj,
|
||||
// because the cloned project is stored in a very different directory.
|
||||
var test_dir = System.IO.Path.GetDirectoryName (original_path);
|
||||
|
||||
// Get all the files in the project directory from git
|
||||
using var process = new Process ();
|
||||
process.StartInfo.FileName = "git";
|
||||
process.StartInfo.Arguments = "ls-files";
|
||||
process.StartInfo.WorkingDirectory = test_dir;
|
||||
var stdout = new MemoryLog () { Timestamp = false };
|
||||
var result = await processManager.RunAsync (process, log, stdout, stdout, timeout: TimeSpan.FromSeconds (15));
|
||||
if (!result.Succeeded)
|
||||
throw new Exception ($"Failed to list the files in the directory {test_dir} (TimedOut: {result.TimedOut} ExitCode: {result.ExitCode}):\n{stdout}");
|
||||
// Get all the files in the project directory from git
|
||||
using var process = new Process ();
|
||||
process.StartInfo.FileName = "git";
|
||||
process.StartInfo.Arguments = "ls-files";
|
||||
process.StartInfo.WorkingDirectory = test_dir;
|
||||
var stdout = new MemoryLog () { Timestamp = false };
|
||||
var result = await processManager.RunAsync (process, log, stdout, stdout, timeout: TimeSpan.FromSeconds (15));
|
||||
if (!result.Succeeded)
|
||||
throw new Exception ($"Failed to list the files in the directory {test_dir} (TimedOut: {result.TimedOut} ExitCode: {result.ExitCode}):\n{stdout}");
|
||||
|
||||
var files = stdout.ToString ().Split ('\n');
|
||||
foreach (var file in files) {
|
||||
var ext = System.IO.Path.GetExtension (file);
|
||||
var full_path = System.IO.Path.Combine (test_dir, file);
|
||||
var windows_file = full_path.Replace ('/', '\\');
|
||||
var files = stdout.ToString ().Split ('\n');
|
||||
foreach (var file in files) {
|
||||
var ext = System.IO.Path.GetExtension (file);
|
||||
var full_path = System.IO.Path.Combine (test_dir, file);
|
||||
var windows_file = full_path.Replace ('/', '\\');
|
||||
|
||||
if (file.Contains (".xcasset")) {
|
||||
doc.AddInclude ("ImageAsset", file, windows_file, true);
|
||||
continue;
|
||||
}
|
||||
if (file.Contains (".xcasset")) {
|
||||
doc.AddInclude ("ImageAsset", file, windows_file, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (ext.ToLowerInvariant ()) {
|
||||
case ".cs":
|
||||
doc.AddInclude ("Compile", file, windows_file, true);
|
||||
break;
|
||||
case ".plist":
|
||||
doc.AddInclude ("None", file, windows_file, true);
|
||||
break;
|
||||
case ".storyboard":
|
||||
doc.AddInclude ("InterfaceDefinition", file, windows_file, true);
|
||||
break;
|
||||
case ".gitignore":
|
||||
case ".csproj":
|
||||
case ".props": // Directory.Build.props
|
||||
case "": // Makefile
|
||||
break; // ignore these files
|
||||
default:
|
||||
Console.WriteLine ($"Unknown file: {file} (extension: {ext}). There might be a default inclusion behavior for this file.");
|
||||
break;
|
||||
switch (ext.ToLowerInvariant ()) {
|
||||
case ".cs":
|
||||
doc.AddInclude ("Compile", file, windows_file, true);
|
||||
break;
|
||||
case ".plist":
|
||||
doc.AddInclude ("None", file, windows_file, true);
|
||||
break;
|
||||
case ".storyboard":
|
||||
doc.AddInclude ("InterfaceDefinition", file, windows_file, true);
|
||||
break;
|
||||
case ".gitignore":
|
||||
case ".csproj":
|
||||
case ".props": // Directory.Build.props
|
||||
case "": // Makefile
|
||||
break; // ignore these files
|
||||
default:
|
||||
Console.WriteLine ($"Unknown file: {file} (extension: {ext}). There might be a default inclusion behavior for this file.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -588,6 +588,14 @@ namespace Microsoft.DotNet.XHarness.iOS.Shared.Utilities {
|
|||
return attrib != null;
|
||||
}
|
||||
|
||||
public static bool? GetEnableDefaultItems (this XmlDocument csproj)
|
||||
{
|
||||
var node = csproj.SelectSingleNode ($"/*/*/*[local-name() = 'EnableDefaultItems']");
|
||||
if (node == null)
|
||||
return null;
|
||||
return string.Equals (node.InnerText, "true", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
static XmlNode GetInfoPListNode (this XmlDocument csproj, bool throw_if_not_found = false)
|
||||
{
|
||||
var logicalNames = csproj.SelectNodes ("//*[local-name() = 'LogicalName']");
|
||||
|
|
Загрузка…
Ссылка в новой задаче