1
0
Форкнуть 0
This commit is contained in:
Sandeep Chakradhari Pedamallu 2015-02-26 23:19:51 -08:00
Родитель 68adcd7c7a
Коммит 32d7d9bdc6
9 изменённых файлов: 526 добавлений и 46 удалений

14
.gitignore поставляемый
Просмотреть файл

@ -10,17 +10,19 @@ target
seed.txt
map.txt
.metadata
sdk/android/src/notifications-handler/libs/google-play-services.jar
sdk/android/src/sdk/libs/gson-2.2.2.jar
sdk/android/test/sdk.testapp.tests/libs/gson-2.2.2.jar
*.mdf
*.ldf
obj
*.csproj.user
test/ZumoE2EServerApp/Properties/PublishProfiles/
sdk/Managed/test/Microsoft.WindowsAzure.MobileServices.SQLiteStore.Net45.Test/sqlite3.dll
StyleCop.Cache
packages
*.suo
*.xccheckout
deriveddata
.nuget
tools-packages
client/dotnet-service
client/web-dotnet/ZUMOAPPNAME/page.tt
client/web-dotnet/ZUMOAPPNAME/styles.css
client/web-dotnet/ZUMOAPPNAME/index.html
client/web-dotnet/ZUMOAPPNAME/index.tt
client/web-dotnet/ZUMOAPPNAME/page.js

Просмотреть файл

@ -0,0 +1,248 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Full" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildProjectDirectory)\tools\Microsoft.WindowsAzure.Mobile.Build.targets" />
<Import Project="$(MSBuildProjectDirectory)\tools\NuGet.targets" />
<PropertyGroup>
<SDKRootPath>$(MSBuildThisFileDirectory)</SDKRootPath>
<QuickStartsSourceDirectory>$(SDKRootPath)\client</QuickStartsSourceDirectory>
<ZipPath>$(SDKRootPath)\packages\7-Zip.CommandLine.9.20.0\tools\7za</ZipPath>
<OutputPath>$(MSBuildThisFileDirectory)\bin</OutputPath>
<DownloadNuGetExe>true</DownloadNuGetExe>
<NugetExe>$(MSBuildProjectDirectory)\.nuget\NuGet.exe</NugetExe>
<DefaultNugetPackageSource>https://www.nuget.org/api/v2/</DefaultNugetPackageSource>
<NugetPackageSource Condition=" '$(NugetPackageSource)' == '' ">$(DefaultNugetPackageSource)</NugetPackageSource>
<!-- Define default configuration (so building from command line is consistent) -->
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<!--TODO : Detect JS SDK version-->
<JSSDKVersion>1.2.7</JSSDKVersion>
</PropertyGroup>
<!-- Quickstarts -->
<ItemGroup>
<!-- Node quickstarts -->
<QuickStart Include="$(MSBuildProjectFile)" >
<Runtime>Node</Runtime>
<SourcePath>web</SourcePath>
<ZipFileName>Html_JavaScript.zip</ZipFileName>
<PackageId/>
</QuickStart>
<QuickStart Include="$(MSBuildProjectFile)">
<Runtime>Node</Runtime>
<SourcePath>windows-universal-cs</SourcePath>
<ZipFileName>Windows_Universal_CS.zip</ZipFileName>
<PackageId>WindowsAzure.MobileServices</PackageId>
</QuickStart>
<QuickStart Include="Windows_Universal_JS">
<Runtime>Node</Runtime>
<SourcePath>windows-universal-js</SourcePath>
<ZipFileName>Windows_Universal_JS.zip</ZipFileName>
<PackageId>WindowsAzure.MobileServices</PackageId>
</QuickStart>
<QuickStart Include="Xamarin_iOS" >
<Runtime>Node</Runtime>
<SourcePath>xamarin.iOS</SourcePath>
<ZipFileName>Xamarin_iOS.zip</ZipFileName>
<PackageId/>
<ComponentId>azure-mobile-services</ComponentId>
</QuickStart>
<QuickStart Include=">Xamarin_Android" >
<Runtime>Node</Runtime>
<SourcePath>xamarin.android</SourcePath>
<ZipFileName>Xamarin_Android.zip</ZipFileName>
<PackageId/>
<ComponentId>azure-mobile-services</ComponentId>
</QuickStart>
<!-- DotNet quickstarts -->
<QuickStart Include="Existing_DotNet">
<Runtime>DotNet</Runtime>
<SourcePath>dotnet-service</SourcePath>
<ZipFileName>Existing_DotNet.zip</ZipFileName>
<PackageId />
</QuickStart>
<QuickStart Include="Html_JavaScript_DotNet" >
<Runtime>DotNet</Runtime>
<SourcePath>web-dotnet</SourcePath>
<ZipFileName>Html_JavaScript_DotNet.zip</ZipFileName>
<PackageId/>
</QuickStart>
<QuickStart Include="Windows_Universal_CS_DotNet">
<Runtime>DotNet</Runtime>
<SourcePath>windows-universal-cs</SourcePath>
<ZipFileName>Windows_Universal_CS_DotNet.zip</ZipFileName>
<PackageId>WindowsAzure.MobileServices</PackageId>
</QuickStart>
<QuickStart Include="Windows_Universal_JS_DotNet">
<Runtime>DotNet</Runtime>
<SourcePath>windows-universal-js</SourcePath>
<ZipFileName>Windows_Universal_JS_DotNet.zip</ZipFileName>
<PackageId>WindowsAzure.MobileServices</PackageId>
</QuickStart>
<QuickStart Include="Xamarin_iOS_DotNet" >
<Runtime>DotNet</Runtime>
<SourcePath>xamarin.iOS</SourcePath>
<ZipFileName>Xamarin_iOS_DotNet.zip</ZipFileName>
<PackageId/>
<ComponentId>azure-mobile-services</ComponentId>
</QuickStart>
<QuickStart Include="Xamarin_Android_DotNet" >
<Runtime>DotNet</Runtime>
<SourcePath>xamarin.android</SourcePath>
<ZipFileName>Xamarin_Android_DotNet.zip</ZipFileName>
<PackageId/>
<ComponentId>azure-mobile-services</ComponentId>
</QuickStart>
</ItemGroup>
<Target Name="BuildQuickStarts">
<!-- Create the Quickstarts directory in bin folder -->
<MakeDir Directories="$(OutputPath)\Quickstarts"/>
<!--Download Nuget.exe (CheckPrerequisistes defined in NuGet.targets)-->
<MakeDir Directories="$(MSBuildProjectDirectory)\.nuget" />
<CallTarget Targets="CheckPrerequisites" />
<!--Restore required nuget packages-->
<Exec Command='"$(NugetExe)" install 7-Zip.CommandLine -source $(DefaultNugetPackageSource) -o "$(MSBuildProjectDirectory)\packages" -Version 9.20.0' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices.Backend -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\backend\dotnet\packages"' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices.Backend.Entity -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\backend\dotnet\packages"' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices.Backend.Tables -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\backend\dotnet\packages"' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\packages\sdk"' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices.SQLiteStore -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\packages\sqllitestore"' LogStandardErrorAsError="true" />
<Exec Command='"$(NugetExe)" install WindowsAzure.MobileServices.WinJS -source $(NugetPackageSource) -o "$(MSBuildProjectDirectory)\packages"' LogStandardErrorAsError="true" />
<!--Find NugetVersion from NugetPackages-->
<GetNugetVersion PackageDirectory="$(MSBuildProjectDirectory)\packages\sdk" NugetId="WindowsAzure.MobileServices*" >
<Output TaskParameter="NugetVersion" PropertyName="SDKPackageVersion" />
</GetNugetVersion>
<Message Text="SDKPackageVersion = $(SDKPackageVersion)" />
<GetNugetVersion PackageDirectory="$(MSBuildProjectDirectory)\packages\sqllitestore" NugetId="WindowsAzure.MobileServices.SQLiteStore*">
<Output TaskParameter="NugetVersion" PropertyName="StorePackageVersion" />
</GetNugetVersion>
<Message Text="StorePackageVersion = $(StorePackageVersion)" />
<GetNugetVersion PackageDirectory="$(MSBuildProjectDirectory)\packages" NugetId="WindowsAzure.MobileServices.WinJS*">
<Output TaskParameter="NugetVersion" PropertyName="WinJSPackageVersion" />
</GetNugetVersion>
<Message Text="WinJSPackageVersion = $(WinJSPackageVersion)" />
<!-- Build DotNet service quickstart -->
<MSBuild Projects="$(MSBuildProjectDirectory)\backend\dotnet\Quickstart.csproj"
Properties="Configuration=$(Configuration)"/>
<!-- Copy the DotNet service quickstart from network share to the bin directory -->
<ItemGroup>
<DotNetService Include="$(MSBuildProjectDirectory)\backend\dotnet\bin\$(Configuration)\Quickstart\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(DotNetService)"
DestinationFiles="@(DotNetService->'$(QuickStartsSourceDirectory)\dotnet-service\%(RecursiveDir)%(Filename)%(Extension)')" />
<!-- We don't want to dublicate web QS files so copy them from Node.js runtime QS to NET runtime QS -->
<ItemGroup>
<WebFiles Include="$(QuickStartsSourceDirectory)\web\*.*" />
</ItemGroup>
<Copy SourceFiles="@(WebFiles)"
DestinationFiles="@(WebFiles->'$(QuickStartsSourceDirectory)\web-dotnet\ZUMOAPPNAME\%(RecursiveDir)%(Filename)%(Extension)')"/>
<!-- Execute the private BuildQuickStart task for each quickstart -->
<ItemGroup Condition="'@(QuickStart)' != '' ">
<_BuildQuickStartsNode Include="$(MSBuildProjectFile)" Condition="'%(QuickStart.Runtime)' == 'Node'">
<AdditionalProperties>
QuickStartPath=%(QuickStart.SourcePath);
QuickStartZipFileName=%(QuickStart.ZipFileName);
QuickStartRuntime=%(QuickStart.Runtime)
</AdditionalProperties>
</_BuildQuickStartsNode>
</ItemGroup>
<MSBuild Projects="$(QuickStartsSourceDirectory)\setup\Setup.csproj" Targets="TransformAll"
Properties="Runtime=NODE;ManagedSDKVersion=$(SDKPackageVersion);JSSDKVersion=$(JSSDKVersion);StoreSDKVersion=$(StorePackageVersion);" />
<MSBuild Projects="@(_BuildQuickStartsNode)" Targets="_BuildQuickStartParallel" />
<!-- Execute the private BuildQuickStart task for each quickstart -->
<ItemGroup Condition="'@(QuickStart)' != ''">
<_BuildQuickStartsDotNet Include="$(MSBuildProjectFile)" Condition="'%(QuickStart.Runtime)' == 'DotNet'">
<AdditionalProperties>
QuickStartPath=%(QuickStart.SourcePath);
QuickStartZipFileName=%(QuickStart.ZipFileName);
QuickStartRuntime=%(QuickStart.Runtime)
</AdditionalProperties>
</_BuildQuickStartsDotNet>
</ItemGroup>
<MSBuild Projects="$(QuickStartsSourceDirectory)\setup\Setup.csproj" Targets="TransformAll"
Properties="Runtime=DOTNET;ManagedSDKVersion=$(SDKPackageVersion);JSSDKVersion=$(JSSDKVersion);StoreSDKVersion=$(StorePackageVersion);" />
<MSBuild Projects="@(_BuildQuickStartsDotNet)" Targets="_BuildQuickStartParallel" />
</Target>
<Target Name="_BuildQuickStartParallel">
<PropertyGroup>
<QuickStartSourceDirectory>$(QuickStartsSourceDirectory)\$(QuickStartPath)</QuickStartSourceDirectory>
<QuickStartOutputDirectory>$(OutputPath)\QuickStarts\$(QuickStartRuntime)\$(QuickStartPath)</QuickStartOutputDirectory>
</PropertyGroup>
<!-- Copy the quickstart from the source directory to the bin directory -->
<ItemGroup>
<QuickStartCopyFiles Include="$(QuickStartSourceDirectory)\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(QuickStartCopyFiles)"
DestinationFiles="@(QuickStartCopyFiles->'$(QuickStartOutputDirectory)\%(RecursiveDir)%(Filename)%(Extension)')"/>
<!-- WinJS is special so we need to copy over the .js files from nuget source -->
<ItemGroup>
<WinJSQuickStartCopyFiles Include="$(SDKRootPath)\packages\WindowsAzure.MobileServices.WinJS.$(WinJSPackageVersion)\content\js\*.*"/>
</ItemGroup>
<Copy Condition="'$(QuickStartPath)' == 'windows-universal-js'"
SourceFiles="@(WinJSQuickStartCopyFiles)"
DestinationFolder="$(QuickStartOutputDirectory)\ZUMOAPPNAME\ZUMOAPPNAME.Windows\js"/>
<Copy Condition="'$(QuickStartPath)' == 'windows-universal-js'"
SourceFiles="@(WinJSQuickStartCopyFiles)"
DestinationFolder="$(QuickStartOutputDirectory)\ZUMOAPPNAME\ZUMOAPPNAME.WindowsPhone\js"/>
<!-- Copy DotNet service project -->
<ItemGroup>
<DotNetService Include="$(OutputPath)\QuickStarts\$(QuickStartRuntime)\dotnet-service\ZUMOAPPNAMEService\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(DotNetService)"
Condition="'$(QuickStartRuntime)' == 'DotNet'"
DestinationFiles="@(DotNetService->'$(QuickStartOutputDirectory)\ZUMOAPPNAMEService\%(RecursiveDir)%(Filename)%(Extension)')"/>
<!-- Delete any .tt & .gitignore files -->
<ItemGroup>
<FilesToDelete Include="$(QuickStartOutputDirectory)\**\*.tt" />
<FilesToDelete Include="$(QuickStartOutputDirectory)\.gitignore" />
</ItemGroup>
<Delete Files="@(FilesToDelete)"/>
<!-- Zip up the quickstart -->
<Exec Command='"$(ZipPath)" a -tzip $(OutputPath)\QuickStarts\$(QuickStartZipFileName) $(QuickStartOutputDirectory)\* '/>
</Target>
<!-- Clean -->
<Target Name="Clean">
<RemoveDir Directories="$(OutputPath)"/>
<RemoveDir Directories="$(MSBuildThisFileDirectory)\packages" />
<RemoveDir Directories="$(MSBuildThisFileDirectory)\backend\dotnet\packages" />
</Target>
<!-- Full -->
<Target Name="Full" DependsOnTargets="Clean;BuildQuickStarts;" />
</Project>

29
README.md Normal file
Просмотреть файл

@ -0,0 +1,29 @@
# QuickStarts for Microsoft Azure Mobile Services
With Microsoft Azure Mobile Services you can add a scalable backend to your connected client applications in minutes.
To learn more, visit our [Developer Center](http://azure.microsoft.com/en-us/develop/mobile/).
## Getting Started
If you are new to Mobile Services, you can get started by following our tutorials for connecting your Mobile
Services cloud backend to [Windows Store apps](http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-get-started/),
[Windows Phone 8 apps](http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-phone-get-started/),
[iOS apps](http://azure.microsoft.com/en-us/documentation/articles/mobile-services-ios-get-started/),
and [Android apps](http://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started/).
## Download Source Code
To get the source code of our SDKs and samples via **git** just type:
git clone https://github.com/Azure/azure-mobile-services.git
cd ./azure-mobile-services/
## Building Quickstarts
Run "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\Microsoft.WindowsAzure.Mobile.Build.msbuild"
Build script downloads latest official nuget packages, updates quickstarts with required versions and dependencies & packs required projects to appropriate quickstarts.
### Prerequisites
.Net Framework 4.0.

Просмотреть файл

@ -1,58 +1,85 @@
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.IO.Compression" #>
<#@ assembly name="System.IO.Compression.FileSystem" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.IO.Compression" #>
<#+
public List<NugetPackage> GetQuickStartTemplates()
{
var quickstart = new List<NugetPackage>();
string srcDirectory = this.Host.ResolveParameterValue("", "", "srcDirectory");
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service", "packages.config")));
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Entity", "packages.config")));
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Tables", "packages.config")));
string srcDirectory = this.Host.ResolveParameterValue("", "", "srcDirectory");
ExtractNuspecFiles(srcDirectory);
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, GetNugetDirectory(srcDirectory, "WindowsAzure.MobileServices.Backend.1.*"), "package.nuspec")));
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, GetNugetDirectory(srcDirectory, "WindowsAzure.MobileServices.Backend.Entity.1.*"), "package.nuspec")));
quickstart.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, GetNugetDirectory(srcDirectory, "WindowsAzure.MobileServices.Backend.Tables.1.*"), "package.nuspec")));
return quickstart.Distinct().ToList();
}
public List<NugetPackage> GetSampleTemplates()
{
var sample = new List<NugetPackage>();
string srcDirectory = this.Host.ResolveParameterValue("", "", "srcDirectory");
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Tables", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Entity", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Mongo", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Storage", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.SignalR", "packages.config")));
sample.AddRange(NugetPackage.ReadPackageConfig(Path.Combine(srcDirectory, "Microsoft.WindowsAzure.Mobile.Service.Security", "packages.config")));
return sample.Distinct().ToList();
}
public string GetHintPath(List<NugetPackage> nugetPackages, string id, string targetFramework=null)
{
var package = nugetPackages.Where(nugetPackage => string.CompareOrdinal(nugetPackage.Id, id) == 0).FirstOrDefault();
return string.Format(@"..\packages\{0}.{1}\lib\{2}", package.Id, package.Version, targetFramework == null ? package.TargetFramework : targetFramework);
return string.Format(@"..\packages\{0}.{1}\lib\{2}", package.Id, package.Version, targetFramework == null ? "net45" : targetFramework);
}
static void ExtractNuspecFiles(string srcDirectory)
{
var directoryInfo = new DirectoryInfo(srcDirectory);
foreach (FileInfo nugetPackage in directoryInfo.GetFiles("*.nupkg", SearchOption.AllDirectories))
{
using (ZipArchive archive = ZipFile.OpenRead(nugetPackage.FullName))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(string.Format("Extracting {0} file", entry.FullName));
entry.ExtractToFile(Path.Combine(nugetPackage.DirectoryName, string.Concat("package.nuspec")), overwrite: true);
}
}
}
}
}
static string GetNugetDirectory(string srcDirectory, string nugetPackage)
{
var directoryInfo = new DirectoryInfo(srcDirectory);
DirectoryInfo nugetPackageInfo = (DirectoryInfo)directoryInfo.GetDirectories(nugetPackage).GetValue(0);
return nugetPackageInfo.Name;
}
public class NugetPackage : IEquatable<NugetPackage>
{
public NugetPackage(string packageId, string version, string targetFramework)
private const string namespaceUri = "http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd";
public NugetPackage(string packageId, string version)
{
this.Id = packageId;
if (version.StartsWith("[") || version.StartsWith("("))
{
version = version.Substring(1);
}
if (version.EndsWith("]") || version.EndsWith(")"))
{
version = version.Substring(0, version.Length - 1);
}
this.Version = version;
this.TargetFramework = targetFramework;
}
public string Id { get; private set; }
public string Version { get; private set; }
public string TargetFramework { get; private set; }
bool IEquatable<NugetPackage>.Equals(NugetPackage other)
{
if (other == null)
@ -60,7 +87,7 @@ public class NugetPackage : IEquatable<NugetPackage>
return false;
}
return string.CompareOrdinal(this.Id, other.Id) == 0 && string.CompareOrdinal(this.Version, other.Version) == 0 && string.CompareOrdinal(this.TargetFramework, other.TargetFramework) == 0;
return string.CompareOrdinal(this.Id, other.Id) == 0 && string.CompareOrdinal(this.Version, other.Version) == 0;
}
public override int GetHashCode()
@ -73,16 +100,23 @@ public class NugetPackage : IEquatable<NugetPackage>
var doc = new XmlDocument();
doc.Load(file);
var xmlNameSpaceManager = new XmlNamespaceManager(doc.NameTable);
xmlNameSpaceManager.AddNamespace("ns", namespaceUri);
var references = new List<NugetPackage>();
foreach (XmlNode package in doc.SelectSingleNode("/packages").ChildNodes)
foreach (XmlNode package in doc.SelectSingleNode("/ns:package/ns:metadata/ns:dependencies", xmlNameSpaceManager).ChildNodes)
{
XmlAttribute developmentDependency = package.Attributes["developmentDependency"];
if (developmentDependency == null || string.CompareOrdinal(developmentDependency.Value, "true") != 0)
{
references.Add(new NugetPackage(package.Attributes["id"].Value, package.Attributes["version"].Value, package.Attributes["targetFramework"].Value));
references.Add(new NugetPackage(package.Attributes["id"].Value, package.Attributes["version"].Value));
}
}
XmlNode version = doc.SelectSingleNode("/ns:package/ns:metadata/ns:version", xmlNameSpaceManager);
XmlNode id = doc.SelectSingleNode("/ns:package/ns:metadata/ns:id", xmlNameSpaceManager);
references.Add(new NugetPackage(id.InnerText, string.Format("[{0}]", version.InnerText)));
return references;
}
}

Просмотреть файл

@ -12,7 +12,6 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TransformOnBuild>true</TransformOnBuild>
<NugetVersion Condition="'$(NugetVersion)' == ''">1.0.0-beta</NugetVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -80,12 +79,12 @@
<ItemGroup>
<None Include="Quickstart\ZUMOAPPNAMEService\packages.tt">
<Generator>CustomTextTemplatingFilePreprocessor</Generator>
<AdditionalArgs> -a !!NugetVersion!$(NugetVersion) -a !!srcDirectory!$(MSBuildThisFileDirectory)..\..\src -out $(OutputPath)\Quickstart\ZUMOAPPNAMEService\packages.config </AdditionalArgs>
<AdditionalArgs> -a !!srcDirectory!$(MSBuildThisFileDirectory)\packages -out $(OutputPath)\Quickstart\ZUMOAPPNAMEService\packages.config </AdditionalArgs>
<LastGenOutput>$(OutputPath)\Quickstart\ZUMOAPPNAMEService\packages.config</LastGenOutput>
</None>
<None Include="Quickstart\ZUMOAPPNAMEService\ZUMOAPPNAMEService.tt">
<Generator>CustomTextTemplatingFilePreprocessor</Generator>
<AdditionalArgs> -a !!NugetVersion!$(NugetVersion) -a !!srcDirectory!$(MSBuildThisFileDirectory)..\..\src -out $(OutputPath)\Quickstart\ZUMOAPPNAMEService\ZUMOAPPNAMEService.csproj </AdditionalArgs>
<AdditionalArgs> -a !!srcDirectory!$(MSBuildThisFileDirectory)\packages -out $(OutputPath)\Quickstart\ZUMOAPPNAMEService\ZUMOAPPNAMEService.csproj </AdditionalArgs>
<LastGenOutput>$(OutputPath)\Quickstart\ZUMOAPPNAMEService\ZUMOAPPNAMEService.csproj</LastGenOutput>
</None>
<None Include="FindDependentNugets.tt" />

Просмотреть файл

@ -1,5 +1,4 @@
<#@template language="c#" hostspecific="true"#>
<# string NugetVersion = this.Host.ResolveParameterValue("", "", "NugetVersion"); #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
@ -71,13 +70,13 @@
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.2.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile.Service">
<HintPath>..\packages\WindowsAzure.MobileServices.Backend.<#= NugetVersion#>\lib\net45\Microsoft.WindowsAzure.Mobile.Service.dll</HintPath>
<HintPath><#= this.GetHintPath(nugetPackages, "WindowsAzure.MobileServices.Backend")#>\Microsoft.WindowsAzure.Mobile.Service.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile.Service.Entity">
<HintPath>..\packages\WindowsAzure.MobileServices.Backend.Entity.<#= NugetVersion#>\lib\net45\Microsoft.WindowsAzure.Mobile.Service.Entity.dll</HintPath>
<HintPath><#= this.GetHintPath(nugetPackages, "WindowsAzure.MobileServices.Backend.Entity")#>\Microsoft.WindowsAzure.Mobile.Service.Entity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile.Service.Tables">
<HintPath>..\packages\WindowsAzure.MobileServices.Backend.Tables.<#= NugetVersion#>\lib\net45\Microsoft.WindowsAzure.Mobile.Service.Tables.dll</HintPath>
<HintPath><#= this.GetHintPath(nugetPackages, "WindowsAzure.MobileServices.Backend.Tables")#>\Microsoft.WindowsAzure.Mobile.Service.Tables.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath><#= this.GetHintPath(nugetPackages, "EntityFramework")#>\EntityFramework.dll</HintPath>

Просмотреть файл

@ -1,5 +1,4 @@
<#@template language="c#" hostspecific="true"#>
<# string NugetVersion = this.Host.ResolveParameterValue("", "", "NugetVersion"); #>
<#@ output extension=".config" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Text" #>
@ -10,13 +9,10 @@
foreach(var nugetPackage in this.GetQuickStartTemplates())
{
#>
<package id ="<#= nugetPackage.Id #>" version="<#= nugetPackage.Version #>" targetFramework="<#= nugetPackage.TargetFramework #>" />
<package id ="<#= nugetPackage.Id #>" version="[<#= nugetPackage.Version #>]" targetFramework="net45" />
<#
}
#>
<package id="WindowsAzure.MobileServices.Backend" version="<#= NugetVersion#>" targetFramework="net45" />
<package id="WindowsAzure.MobileServices.Backend.Tables" version="<#= NugetVersion#>" targetFramework="net45" />
<package id="WindowsAzure.MobileServices.Backend.Entity" version="<#= NugetVersion#>" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="[2.1.0]" targetFramework="net45" />
</packages>
<#@ include file="..\..\FindDependentNugets.tt" #>

Просмотреть файл

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GetNugetVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<PackageDirectory ParameterType="System.String" Required="true" />
<NugetId ParameterType="System.String" Required="true" />
<NugetVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var directoryInfo = new DirectoryInfo(PackageDirectory);
DirectoryInfo nugetPackageInfo = (DirectoryInfo)directoryInfo.GetDirectories(NugetId).GetValue(0);
var regex = new Regex(NugetId);
var split = regex.Split(nugetPackageInfo.Name);
NugetVersion = split[1].Substring(1);
]]>
</Code>
</Task>
</UsingTask>
</Project>

144
tools/NuGet.targets Normal file
Просмотреть файл

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
</PropertyGroup>
<PropertyGroup>
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
</PropertyGroup>
<PropertyGroup>
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
</PropertyGroup>
<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>
<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>
<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>
<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />
<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>