Skip to content

Commit

Permalink
# Updated Scrumptious tutorial end solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Bello Camilletti committed May 17, 2013
1 parent 808382e commit 22acf67
Show file tree
Hide file tree
Showing 50 changed files with 1,364 additions and 1,034 deletions.
132 changes: 71 additions & 61 deletions src/.nuget/NuGet.targets
Expand Up @@ -2,26 +2,59 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<NuGetExePath>$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<PackageSources>""</PackageSources>


<!-- Enable the restore command to run before builds -->
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
<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://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://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>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</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>
<PackagesConfig>packages.config</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>

<!-- Commands -->
<RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)" > NUL</RestoreCommand>
<BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " </RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- Make the build depend on restore packages -->
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
Expand All @@ -35,87 +68,64 @@
</PropertyGroup>

<Target Name="CheckPrerequisites">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="!Exists('$(NuGetExePath)')" />
<!-- 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="Exists('$(PackagesConfig)')" />
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" />
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" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Packaging" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Net" />
<Using Namespace="System.Xml" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
string zipTempPath = null;
try {
OutputFilename = Path.GetFullPath(OutputFilename);
if (File.Exists(OutputFilename)) {
return true;
}
Log.LogMessage("Determining latest version of NuGet.CommandLine...");
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
XmlDocument xml = new XmlDocument();
xml.LoadXml(webClient.DownloadString("http://nuget.org/v1/FeedService.svc/Packages()?$filter=tolower(Id)%20eq%20'nuget.commandline'&$top=1&$orderby=Version%20desc"));
XmlNamespaceManager xns = new XmlNamespaceManager(xml.NameTable);
xns.AddNamespace("atom", "http://www.w3.org/2005/Atom");
xns.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
xns.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
string version = xml.SelectSingleNode("//atom:entry/m:properties/d:Version", xns).InnerText;
string zipUrl = xml.SelectSingleNode("//atom:entry/atom:content", xns).Attributes["src"].Value;
Log.LogMessage("Downloading NuGet.CommandLine v{0}...", version);
zipTempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
webClient.DownloadFile(zipUrl, zipTempPath);
Log.LogMessage("Copying to {0}...", OutputFilename);
using (Package package = Package.Open(zipTempPath)) {
PackagePart exePart = package.GetParts().Where(p => p.Uri.ToString().ToLowerInvariant() == "/tools/nuget.exe").Single();
using (Stream inputStream = exePart.GetStream(FileMode.Open, FileAccess.Read))
using (Stream outputStream = File.Create(OutputFilename)) {
byte[] buffer = new byte[16384];
while (true) {
int read = inputStream.Read(buffer, 0, buffer.Length);
if (read == 0) {
break;
}
outputStream.Write(buffer, 0, read);
}
}
}
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
finally {
if (zipTempPath != null) File.Delete(zipTempPath);
}
]]>
</Code>
</Task>
Expand Down
45 changes: 26 additions & 19 deletions src/Facebook.Scrumptious.WindowsPhone.sln
@@ -1,7 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Scrumptious.WindowsPhone", "facebook-scrumptious-windows-phone\Facebook.Scrumptious.WindowsPhone.csproj", "{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Scrumptious.WindowsPhone", "Facebook.Scrumptious.WindowsPhone\Facebook.Scrumptious.WindowsPhone.csproj", "{003190BF-C4E0-4AC6-9930-A248356B4ECB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F1D0EA42-8CCF-45F4-AE43-AC9F30496E5A}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -13,24 +20,24 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|ARM.ActiveCfg = Debug|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|ARM.Build.0 = Debug|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|ARM.Deploy.0 = Debug|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|x86.ActiveCfg = Debug|x86
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|x86.Build.0 = Debug|x86
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Debug|x86.Deploy.0 = Debug|x86
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|Any CPU.Build.0 = Release|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|Any CPU.Deploy.0 = Release|Any CPU
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|ARM.ActiveCfg = Release|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|ARM.Build.0 = Release|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|ARM.Deploy.0 = Release|ARM
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|x86.ActiveCfg = Release|x86
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|x86.Build.0 = Release|x86
{756FDBA3-1EA8-4518-9A35-CFF2CB07EDCE}.Release|x86.Deploy.0 = Release|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|ARM.ActiveCfg = Debug|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|ARM.Build.0 = Debug|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|ARM.Deploy.0 = Debug|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|x86.ActiveCfg = Debug|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|x86.Build.0 = Debug|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Debug|x86.Deploy.0 = Debug|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|Any CPU.Build.0 = Release|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|Any CPU.Deploy.0 = Release|Any CPU
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|ARM.ActiveCfg = Release|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|ARM.Build.0 = Release|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|ARM.Deploy.0 = Release|ARM
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|x86.ActiveCfg = Release|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|x86.Build.0 = Release|x86
{003190BF-C4E0-4AC6-9930-A248356B4ECB}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
@@ -1,19 +1,20 @@
<Application
x:Class="Facebook.Scrumptious.WindowsPhone.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

<!--Application Resources-->
<Application.Resources>
</Application.Resources>

<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>

<Application
x:Class="Facebook.Scrumptious.WindowsPhone.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:Facebook.Scrumptious.WindowsPhone" x:Key="LocalizedStrings"/>
</Application.Resources>

<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>

</Application>

0 comments on commit 22acf67

Please sign in to comment.