forked from Azure/azure-sdk-for-net
-
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.
Removed pre-built templates. Added project build task, added targets …
…to build.proj, updated Repo-Tasks to build and install VS Project templates. Added tests to buildProjectTask. Updated project template to use latest Client Runtime
- Loading branch information
1 parent
665d487
commit ace6ed0
Showing
23 changed files
with
496 additions
and
12 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
43 changes: 43 additions & 0 deletions
43
...soft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/BuildTasksTest.BuildProjectTemplates.proj
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,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="RunTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<LibraryRoot>..\..\..\</LibraryRoot> | ||
<LibraryToolsFolder>$(LibraryRoot)tools</LibraryToolsFolder> | ||
</PropertyGroup> | ||
<UsingTask TaskName="BuildProjectTemplatesTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" /> | ||
<UsingTask TaskName="DebugTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" /> | ||
|
||
<Target Name="BuildTemplate"> | ||
<Message Text="Executing Test 'BuildTemplate'" /> | ||
<BuildProjectTemplatesTask> | ||
<Output TaskParameter="TaskErrorDetected" PropertyName="BuildTemplateTaskFailed" /> | ||
</BuildProjectTemplatesTask> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'false'" Text="Test Passed !!!!!!!!!!"/> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'true'" Text="!!!!!!!!!! Not expecting errors Test Failed !!!!!!!!!!"/> | ||
<Message Text="'BuildTemplate' finished executing" /> | ||
</Target> | ||
|
||
<Target Name="BT_InvalidOutputDir"> | ||
<Message Text="Executing Test 'BT_InvalidOutputDir'" /> | ||
<BuildProjectTemplatesTask TemplateBuildOutputDirPath="C:\nonExistingDir"> | ||
<Output TaskParameter="TaskErrorDetected" PropertyName="BuildTemplateTaskFailed" /> | ||
</BuildProjectTemplatesTask> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'false'" Text="Test Passed !!!!!!!!!!"/> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'true'" Text="!!!!!!!!!! Not expecting errors Test Failed !!!!!!!!!!"/> | ||
<Message Text="'BT_InvalidOutputDir' finished executing" /> | ||
</Target> | ||
|
||
<Target Name="BT_OutputDirNeedAdminRights"> | ||
<Message Text="Executing Test 'BT_OutputDirNeedAdminRights'" /> | ||
<BuildProjectTemplatesTask TemplateBuildOutputDirPath="$(ProgramFiles)" ContinueOnError="true"> | ||
<Output TaskParameter="TaskErrorDetected" PropertyName="BuildTemplateTaskFailed" /> | ||
</BuildProjectTemplatesTask> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'true'" Text="Expecting Errors, Test Passed !!!!!!!!!!"/> | ||
<Message Condition="'$(BuildTemplateTaskFailed)' == 'false'" Text="!!!!!!!!!! No Errors detected, this is unexpected Test Failed !!!!!!!!!!"/> | ||
<Message Text="'BT_OutputDirNeedAdminRights' finished executing" /> | ||
</Target> | ||
|
||
<Target Name="RunTest" DependsOnTargets="BuildTemplate;BT_InvalidOutputDir;BT_OutputDirNeedAdminRights"> | ||
<Message Text="Test Suite completed"/> | ||
</Target> | ||
</Project> |
90 changes: 90 additions & 0 deletions
90
tools/Microsoft.WindowsAzure.Build.Tasks/BuildProjectTemplatesTask.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,90 @@ | ||
/* | ||
Copyright (c) Microsoft. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
namespace Microsoft.WindowsAzure.Build.Tasks | ||
{ | ||
using System; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using NuGet; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.IO; | ||
using System.IO.Compression; | ||
|
||
public class BuildProjectTemplatesTask : Task | ||
{ | ||
/// <summary> | ||
/// list of directories that contain template data | ||
/// </summary> | ||
IEnumerable<string> TemplateDirList; | ||
|
||
/// <summary> | ||
/// Directory path where the templates will be copied after build | ||
/// </summary> | ||
public string TemplateBuildOutputDirPath { get; set; } | ||
|
||
/// <summary> | ||
/// True: If errors were detected during execution of task | ||
/// False: If no errors were detected during task execution | ||
/// </summary> | ||
[Output] | ||
public bool TaskErrorDetected { get; private set; } | ||
|
||
/// <summary> | ||
/// Initialize data | ||
/// </summary> | ||
private void Init() | ||
{ | ||
TaskErrorDetected = false; | ||
TemplateDirList = new List<string> { @"AutoRest-AzureDotNetSDK", @"AzureDotNetSDK-TestProject" }; | ||
if (!Directory.Exists(TemplateBuildOutputDirPath)) | ||
{ | ||
TemplateBuildOutputDirPath = Environment.GetEnvironmentVariable("Temp"); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Execute Build Template task | ||
/// </summary> | ||
/// <returns></returns> | ||
public override bool Execute() | ||
{ | ||
try | ||
{ | ||
Init(); | ||
string projTemplateBaseDir = Path.Combine(Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).AbsolutePath), "projectTemplates"); | ||
foreach (string templateDir in TemplateDirList) | ||
{ | ||
string autoRestTemplateDir = Path.Combine(projTemplateBaseDir, templateDir); | ||
string zipTemplateFile = Path.GetFullPath(Path.Combine(TemplateBuildOutputDirPath, string.Concat(templateDir, ".zip"))); | ||
if (File.Exists(zipTemplateFile)) | ||
{ | ||
File.Delete(zipTemplateFile); | ||
} | ||
|
||
ZipFile.CreateFromDirectory(autoRestTemplateDir, zipTemplateFile); | ||
Log.LogMessage("Successfully build and copied {0} template to '{1}'", templateDir, zipTemplateFile); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.LogErrorFromException(ex); | ||
TaskErrorDetected = true; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
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,38 @@ | ||
namespace Microsoft.Azure.Build.Tasks | ||
{ | ||
using Microsoft.Build.Utilities; | ||
using System; | ||
using ThreadTask = System.Threading.Tasks; | ||
|
||
|
||
|
||
/// <summary> | ||
/// Utility task to help debug | ||
/// </summary> | ||
public class DebugTask : Microsoft.Build.Utilities.Task | ||
{ | ||
/// <summary> | ||
/// Default timeout | ||
/// </summary> | ||
const int DEFAULT_TASK_TIMEOUT = 20000; | ||
|
||
/// <summary> | ||
/// Task Timeout | ||
/// </summary> | ||
public int Timeoutmiliseconds { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
if (Timeoutmiliseconds == 0) Timeoutmiliseconds = DEFAULT_TASK_TIMEOUT; | ||
|
||
ThreadTask.Task waitingTask = ThreadTask.Task.Run(() => | ||
{ | ||
Console.WriteLine("Press any key to continue or it will continue in {0} seconds", (Timeoutmiliseconds / 1000)); | ||
Console.ReadLine(); | ||
}); | ||
|
||
waitingTask.Wait(TimeSpan.FromMilliseconds(Timeoutmiliseconds)); | ||
return true; | ||
} | ||
} | ||
} |
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
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net45" /> | ||
<package id="NuGet.Core" version="2.12.0" targetFramework="net45" /> | ||
</packages> |
21 changes: 21 additions & 0 deletions
21
tools/ProjectTemplates/AutoRest-AzureDotNetSDK/AutoRest-AzureDotNetSDK.xproj
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>$guid1$</ProjectGuid> | ||
<RootNamespace>$safeprojectname$</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
Binary file not shown.
32 changes: 32 additions & 0 deletions
32
tools/ProjectTemplates/AutoRest-AzureDotNetSDK/MyTemplate.vstemplate
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,32 @@ | ||
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"> | ||
<TemplateData> | ||
<Name>AutoRest-AzureDotNetSDK</Name> | ||
<Description>AutoRest generated project template for Azure .NET SDK</Description> | ||
<ProjectType>DNX</ProjectType> | ||
<ProjectSubType> | ||
</ProjectSubType> | ||
<SortOrder>1000</SortOrder> | ||
<CreateNewFolder>true</CreateNewFolder> | ||
<CreateInPlace>true</CreateInPlace> | ||
<DefaultName>AutoRest-AzureDotNetSDK</DefaultName> | ||
<CreateInPlace>true</CreateInPlace> | ||
<ProvideDefaultName>true</ProvideDefaultName> | ||
<LocationField>Enabled</LocationField> | ||
<EnableLocationBrowseButton>true</EnableLocationBrowseButton> | ||
<Icon>__TemplateIcon.ico</Icon> | ||
</TemplateData> | ||
<TemplateContent> | ||
<Project TargetFileName="AutoRest-AzureDotNetSDK.xproj" File="AutoRest-AzureDotNetSDK.xproj" ReplaceParameters="true"> | ||
<Folder Name="Properties" TargetFolderName="Properties"> | ||
<ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem> | ||
</Folder> | ||
<Folder Name="Generated" TargetFolderName="Generated"> | ||
<Folder Name="Models" TargetFolderName="Models" /> | ||
</Folder> | ||
<ProjectItem ReplaceParameters="false" TargetFileName="MSSharedLibKey.snk">MSSharedLibKey.snk</ProjectItem> | ||
<ProjectItem ReplaceParameters="true" TargetFileName="project.json">project.json</ProjectItem> | ||
<ProjectItem ReplaceParameters="true" TargetFileName="project.lock.json">project.lock.json</ProjectItem> | ||
<ProjectItem ReplaceParameters="true" TargetFileName="Readme.txt" OpenInEditor="true">Readme.txt</ProjectItem> | ||
</Project> | ||
</TemplateContent> | ||
</VSTemplate> |
29 changes: 29 additions & 0 deletions
29
tools/ProjectTemplates/AutoRest-AzureDotNetSDK/Properties/AssemblyInfo.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 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System; | ||
using System.Resources; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("$safeprojectname$")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: NeutralResourcesLanguage("en")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
[assembly: AssemblyTitle("")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
|
||
|
||
|
||
|
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,30 @@ | ||
Changing Package Name | ||
====================== | ||
Project directory name becomes package name by default. | ||
If you would like change the package name of the project do the following | ||
1) Rename the project directory to the desired name. project directory = name of the directory where project.json is located | ||
2) Make the appropriate changes for the AssemblyProduct attribute defined in AssemblyInfo.cs | ||
|
||
Adding code generated from AutoRest | ||
=================================== | ||
1) Add the generated code to the existing Generated directory that you see in the project template | ||
|
||
Adding test project to test your newly added SDK project | ||
======================================================== | ||
1) Click Add new project to the existing solution | ||
2) Search for "AzureDotNetSDK-TestProject" | ||
3) Give appropriate name of your new Test Project, choose the right location | ||
|
||
References: | ||
=========== | ||
If you are adding a new reference, all three targets (.NET45, .NET standard 1.1, .NET standard 1.5) will need to be supported | ||
So add the appropriate reference in project.json for the all the 3 frameworks that are listed in project.json | ||
|
||
For more information please visit | ||
https://github.com/Azure/adx-documentation-pr/blob/master/README.md | ||
|
||
If you do not have access to the above repository, please visit | ||
http://aka.ms/azuregithub | ||
|
||
And join Azure Organization | ||
https://repos.opensource.microsoft.com/Azure/ |
Binary file not shown.
Oops, something went wrong.