Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a way to sign packages outside source directory #4004

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ private void Init()

if (string.IsNullOrEmpty(RemoteRootDir))
{
RemoteRootDir = DEFAULT_REMOTE_ROOT_DIR;
string localCopyFrom = Path.Combine(LocalBranchRootDir, COPY_FROM_RELATIVEPATH);
if(!Directory.Exists(localCopyFrom))
{
RemoteRootDir = DEFAULT_REMOTE_ROOT_DIR;
}
else
{
RemoteRootDir = LocalBranchRootDir;
}
}

if (RemoteRootDir.StartsWith("http"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<PackageId>Microsoft.Azure.Build.BootstrapTasks</PackageId>
<Description>Provides .NET SDK Build bootstrapper tasks</Description>
<AssemblyTitle>Microsoft.Azure.Build.BootstrapperTasks</AssemblyTitle>
<AssemblyName>Microsoft.Azure.Build.BootstrapTasks</AssemblyName>
<Version>1.0.0</Version>
</PropertyGroup>
<PropertyGroup>
<OutputPath>..\..\..\tasks</OutputPath>
<TargetFramework>net46</TargetFramework>
<OutputPath>..\..\..\tasks</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.1.1012" />
<PackageReference Include="Microsoft.Build.Framework" Version="15.1.1012" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.1.1012" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.1012" />
</ItemGroup>

<Target Name="CopyOutput" AfterTargets="AfterBuild">
<Copy
SourceFiles="$(OutputPath)\$(AssemblyName).dll"
DestinationFiles="..\..\..\..\bootstraptools\taskBinaries\Microsoft.Azure.Build.BootstrapTasks.dll"
ContinueOnError="false" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<PackageId>Microsoft.Azure.Sdk.Build.Tasks</PackageId>
<Description>Provides .NET SDK Build tools tasks</Description>
<AssemblyTitle>Microsoft.Azure.Sdk.Build.Tasks</AssemblyTitle>
<AssemblyName>Microsoft.Azure.Sdk.Build.Tasks</AssemblyName>
<Version>1.0.0</Version>
</PropertyGroup>
<PropertyGroup>
<OutputPath>..\..\..\tasks</OutputPath>
<TargetFramework>net46</TargetFramework>
<OutputPath>..\..\..\tasks</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.3.409" />
Expand All @@ -14,15 +19,4 @@
<ItemGroup>
<Folder Include="StaticAnalysisTasks\" />
</ItemGroup>
<ItemGroup>
<!--<Reference Include="Microsoft.Build">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Microsoft.Build.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Framework">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Microsoft.Build.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Tasks.v4.0" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />-->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SDKCategorizeProjects : Task
#region fields
private string KV_IGNOREDIRNAME = "Microsoft.Azure.KeyVault.Samples";
private string _ignoreDirNameForSearchingProjects;
private string _searchProjectFileExt;
#endregion

public SDKCategorizeProjects()
Expand Down Expand Up @@ -79,9 +80,24 @@ public string IgnoreDirNameForSearchingProjects

/// <summary>
/// List of project file extension.
/// Currently only hard coded to .csproj files
/// </summary>
private string SearchProjectFileExt { get; set; }
public string SearchProjectFileExt
{
get
{
if(_searchProjectFileExt == null)
{
_searchProjectFileExt = string.Empty;
}

return _searchProjectFileExt;
}

set
{
_searchProjectFileExt = value;
}
}

#region OUTPUT
/// <summary>
Expand Down Expand Up @@ -123,6 +139,8 @@ public string IgnoreDirNameForSearchingProjects
/// </summary>
[Output]
public ITaskItem[] WellKnowTestSDKNet452Projects { get; private set; }

public string[] UnFilteredProjects { get; private set; }
#endregion

/// <summary>
Expand Down Expand Up @@ -151,7 +169,9 @@ public override bool Execute()
{
ignorePathList.Add(KV_IGNOREDIRNAME);
}
ProjectSearchUtility ProjUtil = new ProjectSearchUtility(SourceRootDirPath, ignorePathList);

string[] projExtList = SearchProjectFileExt?.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
ProjectSearchUtility ProjUtil = new ProjectSearchUtility(SourceRootDirPath, ignorePathList, projExtList);
if (BuildScope.Equals("All", StringComparison.OrdinalIgnoreCase))
{
sdkProjects = ProjUtil.GetAllSDKProjects();
Expand Down Expand Up @@ -190,6 +210,7 @@ public override bool Execute()
netCore11TestProjectsToBuild = testNetCore11Projects?.ToArray<ITaskItem>();
net452TestProjectsToBuild = testNet452Projects?.ToArray<ITaskItem>();
unSupportedProjectsToBuild = unSupportedProjects?.ToArray<ITaskItem>();
UnFilteredProjects = allProjects.ToArray<string>();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ public List<string> GetAllSDKProjects()
public List<string> GetScopedSDKProjects(string scopePath)
{
List<string> scopedProjects = new List<string>();
string searchProjInDirPath = Path.Combine(RootDirForSearch, scopePath);
//string searchProjInDirPath = Path.Combine(RootDirForSearch, scopePath);
string searchProjInDirPath = AdjustPathForScopedProjects(RootDirForSearch, scopePath);
if (Directory.Exists(searchProjInDirPath))
{
scopedProjects = SearchProjects(searchProjInDirPath);
Expand All @@ -192,7 +193,8 @@ public List<string> GetScopedTestProjects(string scopePath)
{
List<string> testScopedProjects = new List<string>();

string searchDir = Path.Combine(RootDirForSearch, scopePath);
//string searchDir = Path.Combine(RootDirForSearch, scopePath);
string searchDir = AdjustPathForScopedProjects(RootDirForSearch, scopePath);
if (Directory.Exists(searchDir))
{
testScopedProjects = SearchTestProjects(searchDir);
Expand Down Expand Up @@ -236,5 +238,32 @@ private List<string> SearchTestProjects(string searchDirPath)
return _testProjs;
}
#endregion

#region Private functions
/// <summary>
/// This function checks if the scope path (which is a relative path) is found under src directory
/// If not found, it will adjust the root directory from the actul root of repo (one level up)
/// Earlier: RootDirForSearch use to be <root>\src
/// But we adjust and move one level up and then search again (if prior attempt resulted in no matching directories)
/// </summary>
/// <param name="rootDir"></param>
/// <param name="scopePath"></param>
/// <returns></returns>
private string AdjustPathForScopedProjects(string rootDir, string scopePath)
{
string rootParentDir = Directory.GetParent(rootDir).FullName;
string searchProjInDirPath = Path.Combine(RootDirForSearch, scopePath);
if (!Directory.Exists(searchProjInDirPath))
{
searchProjInDirPath = Path.Combine(rootParentDir, scopePath);
if (!Directory.Exists(searchProjInDirPath))
{
searchProjInDirPath = string.Empty;
}
}

return searchProjInDirPath;
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,40 @@ public CategorizeProjectTaskTest()
//System.Environment.SetEnvironmentVariable("MSBuildSDKsPath", @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks");
}


[Fact]
public void EmptyProjectExtList()
{
SDKCategorizeProjects cproj = new SDKCategorizeProjects();
cproj.SearchProjectFileExt = null;
cproj.SourceRootDirPath = sourceRootDir;
cproj.BuildScope = @"tools\ProjectTemplates\AzureDotNetSDK-TestProject";
cproj.IgnoreDirNameForSearchingProjects = Path.Combine(ignoreDir);


if (cproj.Execute())
{
Assert.Equal(cproj.UnFilteredProjects.Count<string>(), 0);
}
}

[Fact]
public void GetProjectOutsideSourceDir()
{
SDKCategorizeProjects cproj = new SDKCategorizeProjects();
cproj.SearchProjectFileExt = "*.xproj";
cproj.SourceRootDirPath = sourceRootDir;
cproj.BuildScope = @"tools\ProjectTemplates\AzureDotNetSDK-TestProject";
cproj.IgnoreDirNameForSearchingProjects = Path.Combine(ignoreDir);


if (cproj.Execute())
{
Assert.Equal(cproj.UnFilteredProjects.Count<string>(), 1);
}
}


[Fact]
public void IgnoreDirTokens()
{
Expand Down
Binary file not shown.
Binary file modified tools/BuildAssets/tasks/net46/Microsoft.Azure.Sdk.Build.Tasks.dll
Binary file not shown.
Binary file modified tools/BuildAssets/tasks/net46/Microsoft.Build.Framework.dll
Binary file not shown.
Binary file modified tools/BuildAssets/tasks/net46/Microsoft.Build.Tasks.Core.dll
Binary file not shown.
Binary file not shown.
Binary file modified tools/BuildAssets/tasks/net46/Microsoft.Build.dll
Binary file not shown.
Binary file modified tools/bootstrapTools/Microsoft.Azure.Build.BootstrapTasks.dll
Binary file not shown.
Binary file not shown.