Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

schema creation added

nuget auto-restore added
  • Loading branch information...
commit a96434cb24d69aae18b30dd1fd66a68a5d4a1c27 1 parent 5c5a5fe
Alik Kurdyukov authored
6 .nuget/NuGet.Config
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<configuration>
  3 + <solution>
  4 + <add key="disableSourceControlIntegration" value="true" />
  5 + </solution>
  6 +</configuration>
BIN  .nuget/NuGet.exe
Binary file not shown
150 .nuget/NuGet.targets
... ... @@ -0,0 +1,150 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
  5 +
  6 + <!-- Enable the restore command to run before builds -->
  7 + <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
  8 +
  9 + <!-- Property that enables building a package from a project -->
  10 + <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
  11 +
  12 + <!-- Determines if package restore consent is required to restore packages -->
  13 + <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
  14 +
  15 + <!-- Download NuGet.exe if it does not already exist -->
  16 + <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
  17 + </PropertyGroup>
  18 +
  19 + <ItemGroup Condition=" '$(PackageSources)' == '' ">
  20 + <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
  21 + <!--
  22 + <PackageSource Include="https://nuget.org/api/v2/" />
  23 + <PackageSource Include="https://my-nuget-source/nuget/" />
  24 + -->
  25 + </ItemGroup>
  26 +
  27 + <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
  28 + <!-- Windows specific commands -->
  29 + <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
  30 + <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
  31 + </PropertyGroup>
  32 +
  33 + <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
  34 + <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
  35 + <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
  36 + <PackagesConfig>packages.config</PackagesConfig>
  37 + </PropertyGroup>
  38 +
  39 + <PropertyGroup>
  40 + <!-- NuGet command -->
  41 + <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
  42 + <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
  43 +
  44 + <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
  45 + <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
  46 +
  47 + <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
  48 +
  49 + <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
  50 + <!-- Commands -->
  51 + <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
  52 + <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
  53 +
  54 + <!-- We need to ensure packages are restored prior to assembly resolve -->
  55 + <ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'">
  56 + RestorePackages;
  57 + $(ResolveReferencesDependsOn);
  58 + </ResolveReferencesDependsOn>
  59 +
  60 + <!-- Make the build depend on restore packages -->
  61 + <BuildDependsOn Condition="$(BuildPackage) == 'true'">
  62 + $(BuildDependsOn);
  63 + BuildPackage;
  64 + </BuildDependsOn>
  65 + </PropertyGroup>
  66 +
  67 + <Target Name="CheckPrerequisites">
  68 + <!-- Raise an error if we're unable to locate nuget.exe -->
  69 + <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
  70 + <SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
  71 + <!--
  72 + Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
  73 + This effectively acts as a lock that makes sure that the download operation will only happen once and all
  74 + parallel builds will have to wait for it to complete.
  75 + -->
  76 + <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
  77 + </Target>
  78 +
  79 + <Target Name="_DownloadNuGet">
  80 + <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
  81 + </Target>
  82 +
  83 + <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
  84 + <Exec Command="$(RestoreCommand)"
  85 + Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
  86 +
  87 + <Exec Command="$(RestoreCommand)"
  88 + LogStandardErrorAsError="true"
  89 + Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
  90 + </Target>
  91 +
  92 + <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
  93 + <Exec Command="$(BuildCommand)"
  94 + Condition=" '$(OS)' != 'Windows_NT' " />
  95 +
  96 + <Exec Command="$(BuildCommand)"
  97 + LogStandardErrorAsError="true"
  98 + Condition=" '$(OS)' == 'Windows_NT' " />
  99 + </Target>
  100 +
  101 + <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  102 + <ParameterGroup>
  103 + <OutputFilename ParameterType="System.String" Required="true" />
  104 + </ParameterGroup>
  105 + <Task>
  106 + <Reference Include="System.Core" />
  107 + <Using Namespace="System" />
  108 + <Using Namespace="System.IO" />
  109 + <Using Namespace="System.Net" />
  110 + <Using Namespace="Microsoft.Build.Framework" />
  111 + <Using Namespace="Microsoft.Build.Utilities" />
  112 + <Code Type="Fragment" Language="cs">
  113 + <![CDATA[
  114 + try {
  115 + OutputFilename = Path.GetFullPath(OutputFilename);
  116 +
  117 + Log.LogMessage("Downloading latest version of NuGet.exe...");
  118 + WebClient webClient = new WebClient();
  119 + webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
  120 +
  121 + return true;
  122 + }
  123 + catch (Exception ex) {
  124 + Log.LogErrorFromException(ex);
  125 + return false;
  126 + }
  127 + ]]>
  128 + </Code>
  129 + </Task>
  130 + </UsingTask>
  131 +
  132 + <UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  133 + <ParameterGroup>
  134 + <EnvKey ParameterType="System.String" Required="true" />
  135 + <EnvValue ParameterType="System.String" Required="true" />
  136 + </ParameterGroup>
  137 + <Task>
  138 + <Using Namespace="System" />
  139 + <Code Type="Fragment" Language="cs">
  140 + <![CDATA[
  141 + try {
  142 + Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
  143 + }
  144 + catch {
  145 + }
  146 + ]]>
  147 + </Code>
  148 + </Task>
  149 + </UsingTask>
  150 +</Project>
7 SimpleToDo.sln
@@ -3,6 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 11.00
3 3 # Visual Studio 2010
4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleToDo", "SimpleToDo\SimpleToDo.csproj", "{83E71B0D-37D3-4601-B7E2-552F734D7AC2}"
5 5 EndProject
  6 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{57E27746-5E36-471E-9D09-1D0D7EAB3E08}"
  7 + ProjectSection(SolutionItems) = preProject
  8 + .nuget\NuGet.Config = .nuget\NuGet.Config
  9 + .nuget\NuGet.exe = .nuget\NuGet.exe
  10 + .nuget\NuGet.targets = .nuget\NuGet.targets
  11 + EndProjectSection
  12 +EndProject
6 13 Global
7 14 GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 15 Debug|x86 = Debug|x86
4 SimpleToDo/LocalBootstrapper.cs
@@ -30,8 +30,8 @@ protected override void ConfigureApplicationContainer(IWindsorContainer containe
30 30 container
31 31 .AddFacility<AutoTxFacility>()
32 32 .Register(
33   - Component.For<INHibernateInstaller>().ImplementedBy<NHibInstaller>(),
34   - Component.For<IToDoDao>().ImplementedBy<ToDoDao>()
  33 + Component.For<INHibernateInstaller>().ImplementedBy<NHibInstaller>().LifestyleSingleton(),
  34 + Component.For<IToDoDao>().ImplementedBy<ToDoDao>().LifestyleSingleton()
35 35 )
36 36 .AddFacility<NHibernateFacility>();
37 37 }
6 SimpleToDo/NHibInstaller.cs
@@ -9,6 +9,7 @@
9 9 using NHibernate;
10 10 using NHibernate.Cfg;
11 11 using NHibernate.Mapping.Attributes;
  12 +using NHibernate.Tool.hbm2ddl;
12 13
13 14 namespace SimpleToDo
14 15 {
@@ -50,7 +51,7 @@ public Configuration Config
50 51 IDictionary<string, string> props = new Dictionary<string, string>()
51 52 {
52 53 {"connection.driver_class", "NHibernate.Driver.NpgsqlDriver"},
53   - {"connection.connection_string", "Server=10.211.55.2; Port=5432; User Id=test; Password=test; Database=testdb;"},
  54 + {"connection.connection_string", "Server=localhost; Port=5432; User Id=test; Password=test; Database=testdb;"},
54 55 {"dialect", "NHibernate.Dialect.PostgreSQL82Dialect"},
55 56 {"show_sql", "true"}
56 57 };
@@ -58,6 +59,9 @@ public Configuration Config
58 59 config = new Configuration()
59 60 .SetProperties(props)
60 61 .AddInputStream(HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()));
  62 +
  63 + // apply schema
  64 + new SchemaUpdate(config).Execute(false, true);
61 65 }
62 66 return config;
63 67 }
1  SimpleToDo/SimpleToDo.csproj
@@ -111,6 +111,7 @@
111 111 <None Include="packages.config" />
112 112 </ItemGroup>
113 113 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  114 + <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
114 115 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
115 116 Other similar extension points exist, see Microsoft.Common.targets.
116 117 <Target Name="BeforeBuild">
BIN  lib/Castle.Facilities.NHibernate.dll
Binary file not shown

0 comments on commit a96434c

Please sign in to comment.
Something went wrong with that request. Please try again.