Skip to content

Commit

Permalink
Updates core proj and build to support an old net35 build and output …
Browse files Browse the repository at this point in the history
…to nuget
  • Loading branch information
Shazwazza committed Sep 20, 2018
1 parent 32eb890 commit 9ce1652
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 47 deletions.
15 changes: 15 additions & 0 deletions Build-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ $SolutionInfoPath = Join-Path -Path $SolutionRoot -ChildPath "SolutionInfo.cs"
$SolutionPath = Join-Path -Path $SolutionRoot -ChildPath "ClientDependency.sln"

# clean sln for all deploys
& $MSBuild "$SolutionPath" /p:Configuration=Release-Net35 /maxcpucount /t:Clean
if (-not $?)
{
throw "The MSBuild process returned an error code."
}
& $MSBuild "$SolutionPath" /p:Configuration=Release /maxcpucount /t:Clean
if (-not $?)
{
Expand All @@ -101,6 +106,12 @@ Write-Host "Restoring nuget packages..."

#build for all deploys

# for net 3.5
& $MSBuild "$SolutionPath" /p:Configuration=Release-Net35 /maxcpucount
if (-not $?)
{
throw "The MSBuild process returned an error code."
}
# for net 4.0
& $MSBuild "$SolutionPath" /p:Configuration=Release /maxcpucount
if (-not $?)
Expand Down Expand Up @@ -139,12 +150,16 @@ New-Item $TypeScriptFolder -Type directory

$include = @('ClientDependency.Core.dll','ClientDependency.Core.pdb')
# Need to build to specific .Net version folders
$CoreBinFolderNet35 = Join-Path -Path $SolutionRoot -ChildPath "ClientDependency.Core\bin\Release-Net35";
$CoreBinFolderNet40 = Join-Path -Path $SolutionRoot -ChildPath "ClientDependency.Core\bin\Release";
$CoreBinFolderNet45 = Join-Path -Path $SolutionRoot -ChildPath "ClientDependency.Core\bin\Release-Net45";
$CoreFolderNet35 = Join-Path -Path $CoreFolder -ChildPath "net35";
$CoreFolderNet40 = Join-Path -Path $CoreFolder -ChildPath "net40";
$CoreFolderNet45 = Join-Path -Path $CoreFolder -ChildPath "net45";
New-Item $CoreFolderNet35 -Type directory
New-Item $CoreFolderNet40 -Type directory
New-Item $CoreFolderNet45 -Type directory
Copy-Item "$CoreBinFolderNet35\*.*" -Destination $CoreFolderNet35 -Include $include
Copy-Item "$CoreBinFolderNet40\*.*" -Destination $CoreFolderNet40 -Include $include
Copy-Item "$CoreBinFolderNet45\*.*" -Destination $CoreFolderNet45 -Include $include

Expand Down
91 changes: 76 additions & 15 deletions ClientDependency.Core/BundleManager.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using ClientDependency.Core.Controls;

#if !Net35
using System.Collections.Concurrent;
#endif

namespace ClientDependency.Core
{
Expand All @@ -20,8 +21,12 @@ static BundleManager()

internal static Func<HttpContextBase> GetHttpContextDelegate { get; set; }

#if !Net35
private static readonly ConcurrentDictionary<BundleDefinition, IEnumerable<IClientDependencyFile>> Bundles = new ConcurrentDictionary<BundleDefinition, IEnumerable<IClientDependencyFile>>();

#else
private static readonly Dictionary<BundleDefinition, IEnumerable<IClientDependencyFile>> Bundles = new Dictionary<BundleDefinition, IEnumerable<IClientDependencyFile>>();
private static readonly object DictionaryLocker = new object();
#endif
internal static void ClearBundles()
{
Bundles.Clear();
Expand Down Expand Up @@ -80,10 +85,19 @@ internal static BundleResult GetJsBundle(string bundleName)
return new BundleResult { Definition = b.Key, Files = b.Value };
}

#region CreateCssBundle
#region CreateCssBundle
public static void CreateCssBundle(string name, params CssFile[] files)
{
Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Css, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
var def = new BundleDefinition(ClientDependencyType.Css, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif

}

/// <summary>
Expand All @@ -100,8 +114,16 @@ public static void CreateCssBundle(string name, int priority, params CssFile[] f
{
f.Priority = priority;
}

Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Css, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));

var def = new BundleDefinition(ClientDependencyType.Css, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif
}

/// <summary>
Expand All @@ -126,14 +148,34 @@ public static void CreateCssBundle(string name, int priority, int group, params
f.Group = group;
}

Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Css, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
var def = new BundleDefinition(ClientDependencyType.Css, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif


}
#endregion
#endregion

#region CreateJsBundle
#region CreateJsBundle
public static void CreateJsBundle(string name, params JavascriptFile[] files)
{
Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Javascript, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
var def = new BundleDefinition(ClientDependencyType.Javascript, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif


}

/// <summary>
Expand All @@ -151,7 +193,17 @@ public static void CreateJsBundle(string name, int priority, params JavascriptFi
f.Priority = priority;
}

Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Javascript, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
var def = new BundleDefinition(ClientDependencyType.Javascript, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif


}

/// <summary>
Expand All @@ -176,9 +228,18 @@ public static void CreateJsBundle(string name, int priority, int group, params J
f.Group = group;
}

Bundles.AddOrUpdate(new BundleDefinition(ClientDependencyType.Javascript, name), s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
var def = new BundleDefinition(ClientDependencyType.Javascript, name);
#if !Net35
Bundles.AddOrUpdate(def, s => OrderFiles(files), (s, enumerable) => OrderFiles(files));
#else
lock (DictionaryLocker)
{
Bundles[def] = OrderFiles(files);
}
#endif

}
#endregion
#endregion

/// <summary>
/// This will order the files
Expand Down
11 changes: 10 additions & 1 deletion ClientDependency.Core/ClientDependency.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Net35|AnyCPU'">
<OutputPath>bin\Release-Net35\</OutputPath>
<DefineConstants>TRACE;MVC;Net35</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
Expand Down Expand Up @@ -233,7 +243,6 @@
<None Include="cdf.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ private byte[] ProcessRequestInternal(HttpContextBase context, string fileset, C
{
//Update the XML file map
ClientDependencySettings.Instance.DefaultFileMapProvider.CreateUpdateMap(fileset, clientCompression.ToString(),
fileDefinitions.Select(x => new BasicFile(type) { FilePath = x.Uri }),

#if !Net35
fileDefinitions.Select(x => new BasicFile(type) { FilePath = x.Uri }),
#else
fileDefinitions.Select(x => (IClientDependencyFile)new BasicFile(type) { FilePath = x.Uri }),
#endif
compositeFileName,
version);
}
Expand Down
9 changes: 8 additions & 1 deletion ClientDependency.Core/Config/ClientDependencySection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ public string FileBasedDepdendenyExtensions
[ConfigurationProperty("allowOnlyFipsAlgorithms", DefaultValue = false)]
public bool AllowOnlyFipsAlgorithms
{
get { return CryptoConfig.AllowOnlyFipsAlgorithms; }
get
{
#if !Net35
return CryptoConfig.AllowOnlyFipsAlgorithms;
#else
return false;
#endif
}
set
{
//this does nothing now
Expand Down
4 changes: 4 additions & 0 deletions ClientDependency.Core/Controls/ClientDependencyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

#if !Net35
_base.Paths.UnionWith(Paths);
#else
_base.Paths.UnionWith((IEnumerable<IClientDependencyPath>)Paths);
#endif

RegisterClientDependencies((WebFormsFileRegistrationProvider)_base.Provider, Page, _base.Paths);
RenderDependencies();
Expand Down
8 changes: 8 additions & 0 deletions ClientDependency.Core/CssHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ public static long ParseImportStatements(Stream stream, out IEnumerable<string>
currIndex = -1;
//write to the main imports and reset the temp one
imports.Append(tempImports);
#if !Net35
tempImports.Clear();
#else
tempImports.Length = 0;
#endif
}
}
else if (searchStatement[currIndex + 1] == c)
Expand All @@ -131,7 +135,11 @@ public static long ParseImportStatements(Stream stream, out IEnumerable<string>
{
//reset and start again
currIndex = -1;
#if !Net35
tempImports.Clear();
#else
tempImports.Length = 0;
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ protected void WriteStaggeredDependencies(
//need to force non-bundled lines for items with query parameters or a hash value.
var extension = f.FilePath.Contains('?') || f.FilePath.Contains('#') ? "" : Path.GetExtension(f.FilePath);
var stringExt = "";
#if !Net35
if (!string.IsNullOrWhiteSpace(extension))
#else
if (!string.IsNullOrEmpty(extension))
#endif
{
stringExt = extension.ToUpper().Split(new[] {'?'}, StringSplitOptions.RemoveEmptyEntries)[0];
}
Expand Down
54 changes: 52 additions & 2 deletions ClientDependency.Core/FileWriters.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClientDependency.Core.CompositeFiles;

#if !Net35
using System.Collections.Concurrent;
#endif

namespace ClientDependency.Core
{
/// <summary>
Expand All @@ -13,10 +15,21 @@ namespace ClientDependency.Core
public class FileWriters
{

#if !Net35
private static readonly ConcurrentDictionary<string, IFileWriter> ExtensionWriters = new ConcurrentDictionary<string, IFileWriter>();
private static readonly ConcurrentDictionary<string, IFileWriter> PathWriters = new ConcurrentDictionary<string, IFileWriter>();
private static readonly ConcurrentDictionary<string, IVirtualFileWriter> VirtualExtensionWriters = new ConcurrentDictionary<string, IVirtualFileWriter>();
private static readonly ConcurrentDictionary<string, IVirtualFileWriter> VirtualPathWriters = new ConcurrentDictionary<string, IVirtualFileWriter>();
#else
private static readonly Dictionary<string, IFileWriter> ExtensionWriters = new Dictionary<string, IFileWriter>();
private static readonly Dictionary<string, IFileWriter> PathWriters = new Dictionary<string, IFileWriter>();
private static readonly Dictionary<string, IVirtualFileWriter> VirtualExtensionWriters = new Dictionary<string, IVirtualFileWriter>();
private static readonly Dictionary<string, IVirtualFileWriter> VirtualPathWriters = new Dictionary<string, IVirtualFileWriter>();

private static readonly object DictionaryLocker = new object();
#endif


private static readonly IFileWriter DefaultFileWriter = new DefaultFileWriter();

/// <summary>
Expand Down Expand Up @@ -53,7 +66,17 @@ public static void AddWriterForExtension(string fileExtension, IVirtualFileWrite
{
throw new FormatException("A file extension must begin with a '.'");
}

#if !Net35
VirtualExtensionWriters.AddOrUpdate(fileExtension.ToUpper(), s => writer, (s, fileWriter) => writer);
#else
lock (DictionaryLocker)
{
VirtualExtensionWriters[fileExtension.ToUpper()] = writer;
}
#endif


}

/// <summary>
Expand Down Expand Up @@ -85,7 +108,16 @@ public static void AddWriterForFile(string filePath, IVirtualFileWriter writer)
{
throw new FormatException("A file path must begin with a '/'");
}

#if !Net35
VirtualPathWriters.AddOrUpdate(filePath.ToUpper(), s => writer, (s, fileWriter) => writer);
#else
lock (DictionaryLocker)
{
VirtualPathWriters[filePath.ToUpper()] = writer;
}
#endif

}

/// <summary>
Expand Down Expand Up @@ -118,7 +150,16 @@ public static void AddWriterForExtension(string fileExtension, IFileWriter write
{
throw new FormatException("A file extension must begin with a '.'");
}

#if !Net35
ExtensionWriters.AddOrUpdate(fileExtension.ToUpper(), s => writer, (s, fileWriter) => writer);
#else
lock (DictionaryLocker)
{
ExtensionWriters[fileExtension.ToUpper()] = writer;
}
#endif

}

/// <summary>
Expand Down Expand Up @@ -150,7 +191,16 @@ public static void AddWriterForFile(string filePath, IFileWriter writer)
{
throw new FormatException("A file path must begin with a '/'");
}

#if !Net35
PathWriters.AddOrUpdate(filePath.ToUpper(), s => writer, (s, fileWriter) => writer);
#else
lock (DictionaryLocker)
{
PathWriters[filePath.ToUpper()] = writer;
}
#endif

}

/// <summary>
Expand Down
Loading

0 comments on commit 9ce1652

Please sign in to comment.