1
0
Форкнуть 0
This commit is contained in:
Matt Fei 2018-04-26 13:41:49 -07:00
Родитель d49435b0db
Коммит 9842688a86
31 изменённых файлов: 1923 добавлений и 0 удалений

13
.nuget/NuGet.Config Normal file
Просмотреть файл

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<packageRestore>
<!-- Disables command-line, automatic, and MSBuild-Integrated restore -->
<add key="enabled" value="True" />
</packageRestore>
</configuration>

Двоичные данные
.nuget/NuGet.exe Normal file

Двоичный файл не отображается.

144
.nuget/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>

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

@ -0,0 +1,50 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="tools\WebFormsDependencyInjection.settings.targets"/>
<ItemGroup>
<AssemblyProject Include="src\UnityAdapter\Microsoft.AspNet.WebFormsDependencyInjection.Unity.csproj" />
</ItemGroup>
<ItemGroup>
<TestProject Include="test\UnityAdapter.Test\Microsoft.AspNet.WebFormsDependencyInjection.Unity.Test.csproj" />
</ItemGroup>
<ItemGroup>
<PackageProject Include="src\Packages\Packages.csproj" />
</ItemGroup>
<Target Name="Build" DependsOnTargets="BuildAssemblies;UnitTest;BuildPackages" />
<Target Name="Clean" DependsOnTargets="CleanPackages;CleanAssemblies" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
<Target Name="BuildAssemblies" DependsOnTargets="RestorePackages">
<MSBuild Targets="Build" Projects="@(AssemblyProject);@(TestProject)" />
</Target>
<Target Name="CleanAssemblies">
<MSBuild Targets="Clean" Projects="WebFormsDependencyInjection.sln" />
</Target>
<Target Name="RebuildAssemblies" DependsOnTargets="Clean;Build" />
<!-- Packages build -->
<Target Name="BuildPackages" DependsOnTargets="RestorePackages">
<MSBuild Targets="" Projects="@(PackageProject)" />
</Target>
<Target Name="CleanPackages">
<MSBuild Targets="Clean" Projects="@(PackageProject)" />
</Target>
<Target Name="RebuildPackages" DependsOnTargets="CleanPackages;BuildPackages" />
<Target Name="RestorePackages">
<Exec Command=".nuget\NuGet.exe restore" />
</Target>
<Target Name="UnitTest">
<MSBuild Targets="XunitTest" Projects="@(TestProject)" />
</Target>
<Import Project="tools\WebFormsDependencyInjection.targets"/>
</Project>

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

@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.WebFormsDependencyInjection.Unity", "src\UnityAdapter\Microsoft.AspNet.WebFormsDependencyInjection.Unity.csproj", "{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A7363E1-8E17-4C97-9B94-6BAF1E422361}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{20D2AF61-CF65-409C-95A4-DEA4C9B605F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.WebFormsDependencyInjection.Unity.Test", "test\UnityAdapter.Test\Microsoft.AspNet.WebFormsDependencyInjection.Unity.Test.csproj", "{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}.Release|Any CPU.Build.0 = Release|Any CPU
{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62} = {7A7363E1-8E17-4C97-9B94-6BAF1E422361}
{071D67ED-B0B6-4927-A75D-83DDDC4DD60B} = {20D2AF61-CF65-409C-95A4-DEA4C9B605F6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1B769C6E-7263-47BE-899F-95CA7A165C3F}
EndGlobalSection
EndGlobal

12
build.cmd Normal file
Просмотреть файл

@ -0,0 +1,12 @@
@ECHO OFF
setlocal
set logOptions=/flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
echo Please build from VS 2015(or newer version) Developer Command Prompt
:BUILD
msbuild "%~dp0\WebFormsDependencyInjection.msbuild" %logOptions% /v:m /maxcpucount /nodeReuse:false %*
endlocal

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

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\tools\UnityAdapter.settings.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\tools\WebFormsDependencyInjection.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3E53288E-F0D1-4A06-8FF9-7DC8FADFDC62}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.AspNet.WebFormsDependencyInjection.Unity</RootNamespace>
<AssemblyName>Microsoft.AspNet.WebFormsDependencyInjection.Unity</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<BaseIntermediateOutputPath>..\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<BaseIntermediateOutputPath>..\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>true</DelaySign>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.Abstractions, Version=3.3.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\..\packages\Unity.Abstractions.3.3.0\lib\net47\Unity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Unity.Container, Version=5.8.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\..\packages\Unity.Container.5.8.6\lib\net47\Unity.Container.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\SR.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>SR.resx</DependentUpon>
</Compile>
<Compile Include="UnityContainerAdapter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\SR.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="35MSSharedLib1024.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

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

@ -0,0 +1,24 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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: AssemblyTitle("Microsoft.AspNet.WebFormsDependencyInjection.Unity")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft.AspNet.WebFormsDependencyInjection.Unity")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3e53288e-f0d1-4a06-8ff9-7dc8fadfdc62")]

72
src/UnityAdapter/Resources/SR.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.AspNet.WebFormsDependencyInjection.Unity.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class SR {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal SR() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.WebFormsDependencyInjection.Unity.Resources.SR", typeof(SR).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Cannot register WebObjectActivator more than once..
/// </summary>
internal static string Cannot_Register_WebObjectActivator_More_Than_Once {
get {
return ResourceManager.GetString("Cannot_Register_WebObjectActivator_More_Than_Once", resourceCulture);
}
}
}
}

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

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Cannot_Register_WebObjectActivator_More_Than_Once" xml:space="preserve">
<value>Cannot register WebObjectActivator more than once.</value>
</data>
</root>

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

@ -0,0 +1,95 @@

namespace Microsoft.AspNet.WebFormsDependencyInjection.Unity
{
using global::Unity;
using global::Unity.Exceptions;
using Microsoft.AspNet.WebFormsDependencyInjection.Unity.Resources;
using System;
using System.Collections.Concurrent;
using System.Reflection;
using System.Web;
/// <summary>
/// The Unity adapter for WebObjectActivator
/// </summary>
public class UnityContainerAdapter : IServiceProvider
{
private static UnityContainerAdapter _adapter;
private static object _lock = new object();
private IUnityContainer _container;
private ConcurrentDictionary<Type, bool> _typesCannotResolve = new ConcurrentDictionary<Type, bool>();
internal Func<Type, object> CreateNonPublicInstance =
(serviceType) => Activator.CreateInstance(
serviceType,
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance,
null,
null,
null);
internal UnityContainerAdapter(IUnityContainer container)
{
_container = container;
}
/// <summary>
/// Implementation of IServiceProvider. Asp.net will call this method to
/// create the instances of Page/UserControl/HttpModule etc.
/// </summary>
/// <param name="serviceType"></param>
/// <returns></returns>
public object GetService(Type serviceType)
{
if (_typesCannotResolve.ContainsKey(serviceType))
{
return CreateNonPublicInstance(serviceType);
}
try
{
return _container.Resolve(serviceType);
}
catch (ResolutionFailedException)
{
_typesCannotResolve.TryAdd(serviceType, true);
return CreateNonPublicInstance(serviceType);
}
}
/// <summary>
/// Plugin the adapter to WebObjectActivator and register the types in Unity container
/// </summary>
/// <param name="registerTypes"></param>
/// <returns></returns>
public static IUnityContainer RegisterWebObjectActivator(Action<IUnityContainer> registerTypes)
{
if (registerTypes == null)
{
throw new ArgumentNullException(nameof(registerTypes));
}
if(_adapter != null)
{
throw new InvalidOperationException(SR.Cannot_Register_WebObjectActivator_More_Than_Once);
}
lock (_lock)
{
if (_adapter == null)
{
var container = new UnityContainer();
_adapter = new UnityContainerAdapter(container);
HttpRuntime.WebObjectActivator = _adapter;
registerTypes(container);
return container;
}
else
{
throw new InvalidOperationException(SR.Cannot_Register_WebObjectActivator_More_Than_Once);
}
}
}
}
}

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

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Unity.Abstractions" version="3.3.0" targetFramework="net472" />
<package id="Unity.Container" version="5.8.6" targetFramework="net472" />
</packages>

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

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\tools\WebFormsDependencyInjection.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7EC5863F-7FF1-41C7-A384-8FFF81531E7A}</ProjectGuid>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<ItemGroup>
<NuGetProject Include="UnityAdapter.nupkg\Microsoft.AspNet.WebFormsDependencyInjection.Unity.nuproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="Build">
<MSBuild Projects="@(NuGetProject)" Targets="Build" />
</Target>
<Target Name="Clean">
<MSBuild Projects="@(NuGetProject)" Targets="Clean" />
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>

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

@ -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">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\tools\UnityAdapter.settings.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\tools\WebFormsDependencyInjection.settings.targets" />
<PropertyGroup>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<NuGetPackageId>$(MSBuildProjectName)</NuGetPackageId>
<NuSpecFile>Microsoft.AspNet.WebFormsDependencyInjection.Unity.nuspec</NuSpecFile>
</PropertyGroup>
<ItemGroup>
<NuGetContent Include="$(AssemblyName).dll">
<Source>$(AssemblyPath)</Source>
<Destination>lib\Net472</Destination>
</NuGetContent>
<NuGetContent Include="$(AssemblyName).xml">
<Source>$(OutputPath)</Source>
<Destination>lib\Net472</Destination>
</NuGetContent>
<NuGetContent Include="$(AssemblyName).pdb" Condition="'$(NuGetPackSymbols)' == 'true'">
<Source>$(OutputPath)</Source>
<Destination>lib\Net472</Destination>
</NuGetContent>
<NuGetContentProject Include="$(RepositoryRoot)\src\UnityAdapter\$(MSBuildProjectName).csproj" Condition="'$(NuGetPackSymbols)' == 'true'" />
<NuGetContent Include="Content\Net472\App_Start\*">
<Destination>content\Net472\App_Start</Destination>
</NuGetContent>
</ItemGroup>
<Import Project="$(RepositoryRoot)Tools\NuGetProj.targets"/>
</Project>

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

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$NuGetPackageId$</id>
<version>$NuGetPackageVersion$</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<title>Microsoft ASP.NET WebForms Dependency Injection Unity Adapter</title>
<description>In .Net 4.7.2, asp.net added dependency injection in WebForms. This package is to make it easier to use Unity container in WebForms application.</description>
<summary>A Unity container adapter for HttpRuntime WebObjectActivator.</summary>
<language>en-US</language>
<projectUrl>http://www.asp.net/</projectUrl>
<licenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<tags>ASP.NET WebForms Unity Container IoC UnityContainer</tags>
<dependencies>
<dependency id="Unity.Container" version="$UnityContainerNuGetPackageVersion$" />
<dependency id="WebActivatorEx" version="$WebActivatorExNuGetPackageVersion$" />
</dependencies>
</metadata>
</package>

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

@ -0,0 +1,43 @@
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof($rootnamespace$.UnityActivator), nameof($rootnamespace$.UnityActivator.Start))]
[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof($rootnamespace$.UnityActivator), nameof($rootnamespace$.UnityActivator.Shutdown))]
namespace $rootnamespace$
{
using Unity;
using Microsoft.AspNet.WebFormsDependencyInjection.Unity;
/// <summary>
/// Provides the bootstrapping for integrating Unity with ASP.NET WebForms.
/// </summary>
public static class UnityActivator
{
private static IUnityContainer container;
/// <summary>
/// Integrates Unity when the application starts.
/// </summary>
public static void Start()
{
container = UnityContainerAdapter.RegisterWebObjectActivator(RegisterTypes);
}
/// <summary>
/// Disposes the Unity container when the application is shut down.
/// </summary>
public static void Shutdown()
{
container.Dispose();
}
/// <summary>
/// Register the types in UnityContainer
/// </summary>
public static void RegisterTypes(IUnityContainer container) {
// NOTE: To load from web.config uncomment the line below.
// Make sure to add a Unity.Configuration to the using statements.
// container.LoadConfiguration();
// TODO: Register your type's mappings here.
// container.RegisterType<ISomeInterface, SomeImplementation>();
}
}
}

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

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnityAdapter.Test
{
public class Class1
{
}
}

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

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<Import Project="..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props" Condition="Exists('..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{071D67ED-B0B6-4927-A75D-83DDDC4DD60B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnityAdapter.Test</RootNamespace>
<AssemblyName>UnityAdapter.Test</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.props'))" />
<Error Condition="!Exists('..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets'))" />
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\..\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
</Target>
<Import Project="..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets" Condition="Exists('..\..\packages\xunit.runner.msbuild.2.3.1\build\net452\xunit.runner.msbuild.targets')" />
<Import Project="..\..\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\..\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
</Project>

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

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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: AssemblyTitle("UnityAdapter.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnityAdapter.Test")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("071d67ed-b0b6-4927-a75d-83dddc4dd60b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

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

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.3.1" targetFramework="net472" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net472" />
<package id="xunit.analyzers" version="0.7.0" targetFramework="net472" />
<package id="xunit.assert" version="2.3.1" targetFramework="net472" />
<package id="xunit.core" version="2.3.1" targetFramework="net472" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net472" />
<package id="xunit.extensibility.execution" version="2.3.1" targetFramework="net472" />
<package id="xunit.runner.msbuild" version="2.3.1" targetFramework="net472" developmentDependency="true" />
</packages>

Двоичные данные
tools/35MSSharedLib1024.snk Normal file

Двоичный файл не отображается.

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>

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

@ -0,0 +1,500 @@
<!--
****************************************************************************************************
Project global nuget targets.
Relevant parameters:
* NuSpecFile property:
The name of the project's nuspec file, relative to the project or with full path.
* NuSpecCreateOnMissing property:
When true and the NuSpecFile does not exists, one can be created from params defined by the project.
* NuGetContent, NuSpecMetadata, NuSpecDependency and NuSpecFrameworkAssembly item groups:
Represent the nuspec schema. See item definitions.
* NuGetContentProject: Item containing the project path and used to add Compile (source) items into
the NuGetContent collection for symbol packages.
* SourceRootFullPath: Default value for the NuGetFromProject corresponding item metadata.
* NuSpec[metadataName] property: Following this property name pattern NuSpec metadata items can be
defined in the project, a nuspec file could be fully generated this way.
* NuSpecProperties property:
NuGet supports property replacement in the nuspec file using the '$value$' token notation.
* Note: If NuSpecFile is provided and the project defines some nuspec parameters, values from both are
merged, with precedense taken by the provided parameters. This allows for parameterization of the file.
* NuGetPackOptions property:
Represents the options passed to the NuGet.exe tool in the command line.
* NuGetPackSymbols property:
Determines whether symbols package is built. Ignored if NuGetPackOptions is defined.
* NuGetOutputPath property:
Represents the directory where the package is to be created.
* NuSpecSchemaVersion: represents the nuspec file xml schema version.
****************************************************************************************************-->
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(CustomBeforeNuGetProjTargets)" Condition="Exists('$(CustomBeforeNuGetProjTargets)')"/>
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<OutputPath Condition="'$(OutputPath)' == ''">bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">obj\$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(NuGetPackageLanguage)' != ''">$(IntermediateOutputPath)$(NuGetPackageLanguage)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<!-- The NuGet package name inlcudes the nusepc id and version which are ultimately taken from the NuSpec file. -->
<!-- The nuspec metadata is usually specified in the nuspec file (if provided). When NuSpec<metaName> props are specified they overwrite the nuspec items. -->
<!-- NuGetPackageID and NuSpecID should have the same value, the former is kept for legacy reasons (same for version properties). -->
<NuSpecId Condition="'$(NuSpecId)' == ''">$(MSBuildProjectName)</NuSpecId>
<NuGetPackageId Condition="'$(NuGetPackageId)' == ''">$(NuSpecId)</NuGetPackageId>
<NuGetPackageVersion Condition="'$(NuGetPackageVersion)' == ''">$(NuSpecVersion)</NuGetPackageVersion>
<NuSpecVersion Condition="'$(NuSpecVersion)' == ''">$(NuGetPackageVersion)</NuSpecVersion>
</PropertyGroup>
<PropertyGroup>
<NuSpecSchemaVersion Condition="'$(NuSpecSchemaVersion)' == ''">2</NuSpecSchemaVersion>
<NuGetPackSymbols Condition="'$(NuGetPackOptions.ToLower().Contains(symbols))'">true</NuGetPackSymbols>
<NuGetPackSymbols Condition="'$(NuGetPackSymbols)' == ''">false</NuGetPackSymbols>
<NuSpecFile Condition="'$(NuSpecFile)' == ''">$(MSBuildProjectDirectory)\$(NuGetPackageId).nuspec</NuSpecFile>
<NuSpecFileName>$([System.IO.Path]::GetFileName('$(NuSpecFile)'))</NuSpecFileName>
<NuSpecCreateOnMissing Condition="'$(NuSpecCreateOnMissing)' == ''">true</NuSpecCreateOnMissing>
<NuGetProjectOutputsFile>$(IntermediateOutputPath)$(NuGetPackageId).outputs</NuGetProjectOutputsFile>
</PropertyGroup>
<PropertyGroup Label="NuGet.targets inputs">
<NuGetExePath Condition="!Exists('$(NuGetExePath)')">$([MSBuild]::GetDirectoryNameOfFileAbove('$(MSBuildThisFileFullPath)', '.nuget\nuget.targets'))\.nuget\NuGet.exe</NuGetExePath>
<NuGetInstallPath>$([System.IO.Path]::GetDirectoryName('$(NuGetExePath)'))</NuGetInstallPath>
<PackageOutputDir Condition="'$(NuGetOutputPath)' != ''">$(NuGetOutputPath)</PackageOutputDir>
<PackageOutputDir Condition="'$(PackageOutputDir)' == ''">$(OutputPath)NuGet</PackageOutputDir>
<PackageOutputDir>$(PackageOutputDir.TrimEnd('\'))</PackageOutputDir>
<NuGetOutputPath Condition="'$(NuGetOutputPath)' == ''">$(PackageOutputDir)</NuGetOutputPath>
<ProjectPath>$(IntermediateOutputPath)$(NuSpecFileName)</ProjectPath>
</PropertyGroup>
<PropertyGroup>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '12.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll</CodeTaskFactoryAssemblyFile>
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskFactoryAssemblyFile>
</PropertyGroup>
<PropertyGroup>
<!--Force a rebuild if this file is changed -->
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath);$(MSBuildProjectFullPath)</MSBuildAllProjects>
</PropertyGroup>
<!--
NuGet package layout conventions http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Package_Conventions
NuSpec metadata schema https://nuget.codeplex.com/wikipage?title=.nuspec%20v1.2%20Format
-->
<ItemDefinitionGroup>
<!-- NuGetContent represents the files to be packed (dll, exe, pdb, .cs, content, etc). -->
<NuGetContent>
<Source>$(NuGetContentSource)</Source>
<Destination>$(NuGetContentDestination)</Destination>
</NuGetContent>
<!-- NuSpecMetadata represents the simple items under the 'metadata' schema element (title, version, etc.) -->
<NuSpecMetadata>
<Value/>
</NuSpecMetadata>
<!-- NuSpecDependency represents the child element of the complex 'metadata/dependencies' schema element. -->
<NuSpecDependency>
<Version/>
<TargetFramework/>
</NuSpecDependency>
<!-- NuSpecFrameworkAssembly represents the child element of the complex 'metadata/frameworkAssemblies' schema element. -->
<NuSpecFrameworkAssembly>
<TargetFramework/>
</NuSpecFrameworkAssembly>
</ItemDefinitionGroup>
<!--
NuGetContentFromProject: Defines content from the Compile item collection (source files) from projects into the NuGetContent item.
-->
<ItemDefinitionGroup>
<NuGetContentProject>
<SourceRootFullPath>$(SourceRootFullPath)</SourceRootFullPath>
<Destination>src</Destination>
</NuGetContentProject>
</ItemDefinitionGroup>
<ItemGroup>
<!-- NuSpec file added by default. -->
<NuGetContent Include="$(ProjectPath)" />
</ItemGroup>
<!-- Optional NuSpec file metadata items. When provided, items are used for generating the final nuspec file. -->
<!-- http://docs.nuget.org/docs/reference/nuspec-reference -->
<ItemGroup>
<NuSpecMetadata Include="id" Condition="'$(NuSpecId)' != ''">
<Value>$(NuSpecId)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="version" Condition="'$(NuSpecVersion)' != ''">
<Value>$(NuSpecVersion)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="title" Condition="'$(NuSpecTitle)' != ''">
<Value>$(NuSpecTitle)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="authors" Condition="'$(NuSpecAuthors)' != ''">
<Value>$(NuSpecAuthors)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="owners" Condition="'$(NuSpecOwners)' != ''">
<Value>$(NuSpecOwners)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="description" Condition="'$(NuSpecDescription)' != ''">
<Value>$(NuSpecDescription)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="tags" Condition="'$(NuSpecTags)' != ''">
<Value>$(NuSpecTags)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="iconUrl" Condition="'$(NuSpecIconUrl)' != ''">
<Value>$(NuSpecIconUrl)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="projectUrl" Condition="'$(NuSpecProjectUrl)' != ''">
<Value>$(NuSpecProjectUrl)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="licenseUrl" Condition="'$(NuSpecLicenseUrl)' != ''">
<Value>$(NuSpecLicenseUrl)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="copyright" Condition="'$(NuSpecCopyright)' != ''">
<Value>$(NuSpecCopyright)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="requireLicenseAcceptance" Condition="'$(NuSpecRequireLicenseAcceptance)' != ''">
<Value>$(NuSpecRequireLicenseAcceptance)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="releaseNotes" Condition="'$(NuSpecReleaseNotes)' != ''">
<Value>$(NuSpecReleaseNotes)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="summary" Condition="'$(NuSpecSummary)' != ''">
<Value>$(NuSpecSummary)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="developmentDependency" Condition="'$(NuSpecDevelopmentDependency)' != ''">
<Value>$(NuSpecDevelopmentDependency)</Value>
</NuSpecMetadata>
<NuSpecMetadata Include="language" Condition="'$(NuSpecLanguage)' != ''">
<Value>$(NuSpecLanguage)</Value>
</NuSpecMetadata>
</ItemGroup>
<ItemGroup>
<Clean Include="$(NuGetProjectOutputsFile)" />
</ItemGroup>
<!--
****************************************************************************************************
Common build targets overwrites.
**************************************************************************************************** -->
<PropertyGroup>
<BuildDependsOn>BeforeBuild;GetNuGetContentFromProject;ValidateNuGetParams;ReadNuGetCleanOutputs;GetNuGetProjectInputs;GetNuGetProjectOutputs;ValidateOutputs;NuGetPack;WriteNuGetProjectOutputs;AfterBuild</BuildDependsOn>
<CleanDependsOn>BeforeClean;ReadNuGetCleanOutputs;CoreClean;AfterClean</CleanDependsOn>
<RebuildDependsOn>Clean;Build</RebuildDependsOn>
</PropertyGroup>
<Target Name="BeforeBuild" />
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="AfterBuild" />
<Target Name="BeforeClean" />
<Target Name="Clean" DependsOnTargets="$(CleanDependsOn)"/>
<Target Name="AfterClean" />
<Target Name="CoreClean">
<Delete Files="@(Clean)" />
<ItemGroup>
<Clean Remove="@(Clean)" />
</ItemGroup>
</Target>
<Target Name="Rebuild" DependsOnTargets="$(RebuildDependsOn)" />
<!--
****************************************************************************************************
GetNuGetContentFromProject: Gets Compile item collection (source files) from projects into the NuGetContent item.
Input: NuGetContentProject and SourceRootFullPath
**************************************************************************************************** -->
<Target Name="GetNuGetContentFromProject" Condition="'@(NuGetContentProject)' != ''">
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="GetNuGetContentFromProjectCore"
Properties="NuGetContentProject=%(NuGetContentProject.FullPath);SourceRootFullPath=%(SourceRootFullPath);Destination=%(Destination)" >
<Output TaskParameter="TargetOutputs" ItemName="NuGetContent" />
</MSBuild>
</Target>
<Target Name="GetNuGetContentFromProjectCore" Outputs="@(NuGetContent)">
<Error Condition="'$(SourceRootFullPath)' == ''" Text="NuGetContentProject item does not define 'SourceRootFullPath' metadata: $(NuGetContentProject)" />
<PropertyGroup>
<!-- Normalize path (remove extra back-slashes and trim) -->
<SourceRootFullPath>$([System.IO.Path]::GetFullPath($(SourceRootFullPath)))</SourceRootFullPath>
</PropertyGroup>
<MSBuild Projects="$(NuGetContentProject)" Targets="GetCompile" RebaseOutputs="true">
<Output TaskParameter="TargetOutputs" ItemName="Compile" />
</MSBuild>
<ItemGroup>
<NugetContent Include="%(Compile.FullPath)" Condition="$([System.String]::Concat(%(FullPath)).ToLower().Contains($(SourceRootFullPath.ToLower())))">
<Destination>$([System.IO.Path]::Combine($(Destination), $([MSBuild]::MakeRelative($([System.IO.Path]::GetFullPath($(SourceRootFullPath))), %(Compile.RootDir)%(Directory)))))</Destination>
</NugetContent>
</ItemGroup>
</Target>
<!--
****************************************************************************************************
ValidateNuGetParams: validate input params.
****************************************************************************************************-->
<Target Name="ValidateNuGetParams">
<ItemGroup>
<PropMismatch Include="NuSpecID=$(NuSpecID) and NuGetPackageID=$(NuGetPackageID)"
Condition="'$(NuSpecId)' != '' AND '$(NuGetPackageID)' != '' AND '$(NuSpecId)' != '$(NuGetPackageID)'" />
<PropMismatch Include="NuSpecVersion=$(NuSpecVersion) and NuGetPackageVersion=$(NuGetPackageVersion)"
Condition="'$(NuSpecVersion)' != '' AND '$(NuGetPackageVersion)' != '' AND '$(NuSpecVersion)' != '$(NuGetPackageVersion)'" />
</ItemGroup>
<Warning Text="No content was specified " Condition="'@(NuGetContent)' == '' AND '$(DisableNoNuGetContentWarning)' != 'true'" />
<Error Text="@(PropMismatch -> '%(Identity) are different, this is an indication of an authoring error!', '%0A')" Condition="'@(PropMismatch)' != ''" />
<Error Text="Could not find nuspec file: $(NuSpecFile)" Condition="!Exists('$(NuSpecFile)') AND '$(NuSpecCreateOnMissing)' == 'false'" />
</Target>
<!--
****************************************************************************************************
ValidateOutputs: checks whether outputs are up-to-date with respect to the inputs to avoid rebuilding
if not needed and play nicely when building incrementally.
**************************************************************************************************** -->
<Target Name="ValidateOutputs" Inputs="@(NuGetProjectInput);$(MSBuildAllProjects)" Outputs="@(NuGetProjectOutput)">
<CreateProperty Value="true">
<Output TaskParameter="ValueSetByTask" PropertyName="OutputsOutdated"/>
</CreateProperty>
</Target>
<!--
****************************************************************************************************
NuGetPack: Creates a nuget package.
**************************************************************************************************** -->
<Target Name="NuGetPack" DependsOnTargets="GenerateNuSpecFile" Condition="'$(OutputsOutdated)' == 'true'">
<ItemGroup>
<!-- Normalize comman-separated property string (removes new lines and trims string)-->
<NuSpecProperties Include="$(NuSpecProperties)" />
</ItemGroup>
<PropertyGroup>
<NuSpecProperties>@(NuSpecProperties)</NuSpecProperties>
<NuGetPackOptions Condition="'$(NuGetPackOptions)' == '' AND '$(NuGetPackSymbols)' != 'true'">-NoPackageAnalysis</NuGetPackOptions>
<NuGetPackOptions Condition="'$(NuGetPackOptions)' == '' AND '$(NuGetPackSymbols)' == 'true'">-NoPackageAnalysis -symbols</NuGetPackOptions>
<!-- BuildCommand is defined in nuget.targets file -->
<BuildCommand>$(BuildCommand.Replace('-symbols', ''))</BuildCommand>
<BuildCommand>$(BuildCommand.Replace('/symbols', ''))</BuildCommand>
<BuildCommand Condition="'$(NuSpecProperties)' != ''">$(BuildCommand) -Properties "$(NuSpecProperties)"</BuildCommand>
<BuildCommand Condition="'$(NuGetPackOptions)' != ''">$(BuildCommand) $(NuGetPackOptions)</BuildCommand>
</PropertyGroup>
<!-- Invalidate outputs to force a full build in case of failure -->
<Delete Files="$(NuGetPackTargetFile)" />
<MakeDir Directories="$(PackageOutputDir)" />
<Exec Command="$(BuildCommand)" StandardOutputImportance="high" StandardErrorImportance="high" WorkingDirectory="$(MSBuildProjectDirectory)" CustomErrorRegularExpression="invalid"/>
<ItemGroup>
<Clean Include="$(PackageOutputDir)\$(NuGetPackageId).$(NuGetPackageVersion)*.nupkg" />
</ItemGroup>
<!-- This target can fail preventing outputs file from being updated, neet to account for that. -->
<OnError ExecuteTargets="WriteNuGetProjectOutputs" />
</Target>
<!--
****************************************************************************************************
GetNuGetProjectInputs: get the project inputs.
**************************************************************************************************** -->
<Target Name="GetNuGetProjectInputs">
<NormalizeNuGetContent NuGetContent="@(NuGetContent)">
<Output TaskParameter="NuGetContentNormalized" ItemName="NuGetProjectInput" />
</NormalizeNuGetContent>
</Target>
<!--
****************************************************************************************************
GetNuGetProjectOutputs: Reads build-generated files from outputs file.
**************************************************************************************************** -->
<Target Name="GetNuGetProjectOutputs">
<PropertyGroup>
<NuGetPackTargetFile>$(PackageOutputDir)\$(NuGetPackageId).$(NuGetPackageVersion).nupkg</NuGetPackTargetFile>
<NuGetPackTargetFile Condition="'$(NuGetPackSymbols)' == 'true'">$(PackageOutputDir)\$(NuGetPackageId).$(NuGetPackageVersion).symbols.nupkg</NuGetPackTargetFile>
</PropertyGroup>
<ItemGroup>
<NuGetProjectOutput Include="$(NuGetPackTargetFile)" />
<NuGetProjectOutput Include="$(NuGetProjectOutputsFile)" />
</ItemGroup>
</Target>
<!--
****************************************************************************************************
ReadNuGetCleanOutputs: Reads build-generated files from outputs file into Clean item collection to
get them re-written into outputs file so they can be cleaned up later.
**************************************************************************************************** -->
<Target Name="ReadNuGetCleanOutputs">
<ReadLinesFromFile File="$(NuGetProjectOutputsFile)">
<Output TaskParameter="Lines" ItemName="Clean" />
</ReadLinesFromFile>
</Target>
<!--
****************************************************************************************************
WriteNuGetProjectOutputs: write the list of build-generated files into outputs file which is used for
cleaning and incremental build.
**************************************************************************************************** -->
<Target Name="WriteNuGetProjectOutputs" Condition="'$(OutputsOutdated)' == 'true'">
<ItemGroup>
<NuGetProjectOutput Include="@(Clean->Distinct())" />
</ItemGroup>
<WriteLinesToFile File="$(NuGetProjectOutputsFile)" Lines="@(NuGetProjectOutput->Distinct())" Overwrite="true" Condition="'@(NuGetProjectOutput)' != ''" />
</Target>
<!--
****************************************************************************************************
GenerateNuSpecFile: generates the final nuspec file for the package.
**************************************************************************************************** -->
<Target Name="GenerateNuSpecFile" DependsOnTargets="GetNuGetProjectInputs" Condition="'$(OutputsOutdated)' == 'true'">
<GenerateNuSpecFile NuSpecFile="$(NuSpecFile)" OutputDir="$(IntermediateOutputPath)" CreateNuSpec="$(NuSpecCreateOnMissing)" MetadataItems="@(NuSpecMetadata)"
Files="@(NuGetProjectInput);@(NuGetContentFromPdb)" FrameworkAssemblies="@(NuSpecFrameworkAssembly)" Dependencies="@(NuSpecDependency)" SchemaVersion="$(NuSpecSchemaVersion)">
<Output TaskParameter="GeneratedNuSpec" PropertyName="GeneratedNuSpec" />
</GenerateNuSpecFile>
<ItemGroup>
<Clean Include="$(GeneratedNuSpec)" />
</ItemGroup>
<Message Text="Generated NuSpec file: $(GeneratedNuSpec)" />
</Target>
<!--
==================================================================================================
Generates final nuspec file combining/replacing values from project nuspec file if provided.
==================================================================================================-->
<UsingTask TaskName="GenerateNuSpecFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
<ParameterGroup>
<NuSpecFile Required="true" ParameterType="System.String" />
<MetadataItems Required="false" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Files Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<FrameworkAssemblies Required="false" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<Dependencies Required="false" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<OutputDir Required="true" ParameterType="System.String" />
<CreateNuSpec Required="false" ParameterType="System.Boolean" />
<SchemaVersion Required="true" ParameterType="System.Int32" />
<GeneratedNuSpec Output="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Using Namespace="System.Linq" />
<Using Namespace="System.IO" />
<Using Namespace="System.Xml.Linq" />
<Code Type="Fragment" Language="cs">
<![CDATA[
XElement packageNode = null;
if (File.Exists(NuSpecFile)) {
packageNode = XElement.Load(NuSpecFile);
} else {
if (!CreateNuSpec) { Log.LogError("NuSpec file does not exist: {0}", NuSpecFile); return false; }
if(SchemaVersion > 1) {
XNamespace pkgNs = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd";
packageNode = new XElement(pkgNs + "package", new XElement("metadata", new XAttribute("schemaVersion", SchemaVersion)));
} else {
packageNode = new XElement("package", new XElement("metadata"));
}
}
GeneratedNuSpec = Path.GetFullPath(Path.Combine(OutputDir, Path.GetFileName(NuSpecFile)));
if (File.Exists(GeneratedNuSpec)) File.Delete(GeneratedNuSpec);
XNamespace ns = packageNode.Name.Namespace;
if(packageNode.Name.LocalName != "package") { Log.LogError("NuSpec file missing 'package' schema element. Found:'{0}'", packageNode.Name.LocalName); return false; };
if (Files == null) Files = new TaskItem[] { };
if (Dependencies == null) Dependencies = new TaskItem[] { };
if (MetadataItems == null) MetadataItems = new TaskItem[] { };
if (FrameworkAssemblies == null) FrameworkAssemblies = new TaskItem[] { };
// replace/add simple metadata.
XElement metadataNode = packageNode.FirstNode as XElement;
if(metadataNode == null) { Log.LogError("NuSpec file missing 'metadata' schema element"); return false; };
foreach (var metaItem in MetadataItems) {
string name = metaItem.GetMetadata("Identity");
string value = metaItem.GetMetadata("Value");
XElement xnode = metadataNode.Descendants(ns + name).FirstOrDefault<XElement>();
if (xnode == null) { xnode = new XElement(name); metadataNode.Add(xnode); }
xnode.Value = value;
}
// replaceable values for dependencies and frameworkassemblies - just replace the whole node.
var removeQ1 = from dependencyNode in packageNode.Descendants(ns + "dependency").Attributes("id")
from dependencyItem in Dependencies
where dependencyItem.GetMetadata("Identity").ToLower().Equals(dependencyNode.Value.ToLower())
select dependencyNode.Parent;
var removeQ2 = from assemblyNode in packageNode.Descendants(ns + "frameworkAssembly").Attributes("assemblyName")
from assemblyItem in FrameworkAssemblies
where assemblyItem.GetMetadata("Identity").ToLower().Equals(assemblyNode.Value.ToLower())
select assemblyNode.Parent;
foreach (var node in removeQ1.ToArray<XElement>()) node.Remove();
foreach (var node in removeQ2.ToArray<XElement>()) node.Remove();
XElement filesNode = packageNode.Descendants(ns + "files").FirstOrDefault<XElement>();
if (filesNode == null) {
filesNode = new XElement("files");
packageNode.Add(filesNode);
}
filesNode.Add(from fi in Files select new XElement("file", new XAttribute("src", fi.GetMetadata("FullPath")), new XAttribute("target", fi.GetMetadata("Destination"))));
XElement frameworkAssembliesNode = packageNode.Descendants(ns + "frameworkAssemblies").FirstOrDefault<XElement>();
if (frameworkAssembliesNode == null) {
frameworkAssembliesNode = new XElement("frameworkAssemblies");
metadataNode.Add(frameworkAssembliesNode);
}
frameworkAssembliesNode.Add(from assembly in FrameworkAssemblies select new XElement("frameworkAssembly",
new XAttribute("assemblyName", assembly.GetMetadata("Identity")), new XAttribute("targetFramework", assembly.GetMetadata("TargetFramework"))));
XElement dependenciesNode = packageNode.Descendants(ns + "dependencies").FirstOrDefault<XElement>();
if (dependenciesNode == null) {
dependenciesNode = new XElement("dependencies");
metadataNode.Add(dependenciesNode);
}
if(SchemaVersion > 1) {
var depGroupsQ = from dp in Dependencies group dp by dp.GetMetadata("TargetFramework");
foreach (var dpGroup in depGroupsQ) {
XElement depGroupNode = new XElement("group");
string targetFx = dpGroup.First().GetMetadata("TargetFramework");
if(!string.IsNullOrEmpty(targetFx)) depGroupNode.Add(new XAttribute("targetFramework", dpGroup.First().GetMetadata("TargetFramework")));
foreach(var depItem in dpGroup) {
XElement dependencyNode = new XElement("dependency", new XAttribute("id", depItem.GetMetadata("Identity")), new XAttribute("version", depItem.GetMetadata("Version")));
depGroupNode.Add(dependencyNode);
}
dependenciesNode.Add(depGroupNode);
}
} else {
dependenciesNode.Add(from dp in Dependencies select new XElement("dependency", new XAttribute("id", dp.GetMetadata("Identity")), new XAttribute("version", dp.GetMetadata("Version"))));
}
if (!Directory.Exists(OutputDir)) Directory.CreateDirectory(OutputDir);
packageNode.Save(GeneratedNuSpec);
]]>
</Code>
</Task>
</UsingTask>
<!--
****************************************************************************************************
NormalizeNuGetContent: Normalize NuGetContent items full path and destination for packing.
****************************************************************************************************-->
<UsingTask TaskName="NormalizeNuGetContent" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
<ParameterGroup>
<NuGetContent Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<NuGetContentNormalized Output="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
NuGetContentNormalized = new TaskItem[NuGetContent.Length];
for (int idx = 0; idx < NuGetContent.Length; idx++) {
string src = NuGetContent[idx].GetMetadata("Source");
string id = NuGetContent[idx].GetMetadata("Identity");
if (!string.IsNullOrEmpty(src) && !Path.IsPathRooted(id)) {
NuGetContentNormalized[idx] = new TaskItem(Path.Combine(src, id));
}
else {
NuGetContentNormalized[idx] = new TaskItem(NuGetContent[idx].GetMetadata("FullPath"));
}
NuGetContentNormalized[idx].SetMetadata("Destination", NuGetContent[idx].GetMetadata("Destination"));
}
]]>
</Code>
</Task>
</UsingTask>
<Import Project="$(NuGetInstallPath)\nuget.targets" />
<Import Project="$(CustomAfterNuGetProjTargets)" Condition="Exists('$(CustomAfterNuGetProjTargets)')"/>
</Project>

Двоичные данные
tools/NuProj.Tasks.dll Normal file

Двоичный файл не отображается.

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

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
DEFAULTS
Those can be overriden.
-->
<PropertyGroup>
<OutDir Condition=" '$(OutDir)' == ''" >$(MSBuildProjectDirectory)\bin\</OutDir>
<IntermediateOutputPath Condition=" '$(IntermediateOutputPath)' == '' ">$(MSBuildProjectDirectory)\obj\</IntermediateOutputPath>
<NuSpecPath Condition=" '$(NuSpecPath)' == '' ">$(IntermediateOutputPath)$(Id).nuspec</NuSpecPath>
<NuProjTasksPath Condition=" '$(NuProjTasksPath)' == '' ">$(MSBuildThisFileDirectory)NuProj.Tasks.dll</NuProjTasksPath>
<NuGetToolPath Condition=" '$(NuGetToolPath)' == '' ">$(MSBuildThisFileDirectory)</NuGetToolPath>
<NuGetToolExe Condition=" '$(NuGetToolExe)' == '' ">NuGet.exe</NuGetToolExe>
</PropertyGroup>
<!--
OUPUT PATH
This property isn't passed to NuGet.exe - it's implicit. However, we need to know the ouput path
at several occasions (e.g. incremental build or clean up) so we want a central spot to capture it.
-->
<PropertyGroup>
<NuGetOuputPath>$(OutDir)$(Id).$(Version).nupkg</NuGetOuputPath>
</PropertyGroup>
<!--
MSBuildAllProjects is used to keep track of all projects the build depends on.
We make all targets depending on it to make sure everything rebuilds.
-->
<PropertyGroup>
<MSBuildAllProjects Condition="Exists('$(MSBuildProjectFullPath)')">$(MSBuildAllProjects);$(MSBuildProjectFullPath)</MSBuildAllProjects>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<!--
CUSTOM TASKS
-->
<UsingTask TaskName="GenerateNuSpec" AssemblyFile="$(NuProjTasksPath)" />
<UsingTask TaskName="NuGetPack" AssemblyFile="$(NuProjTasksPath)" />
<!--
CONVERT ITEMS
-->
<Target Name="ConvertItems">
<CreateItem Include="@(Library)"
AdditionalMetadata="TargetPath=lib\%(Library.TargetFramework)">
<Output TaskParameter="Include"
ItemName="File"/>
</CreateItem>
<CreateItem Include="@(Content)"
AdditionalMetadata="TargetPath=content\%(Content.TargetPath)">
<Output TaskParameter="Include"
ItemName="File"/>
</CreateItem>
</Target>
<!--
GENERATE NU SPEC
-->
<Target Name="GenerateNuSpec"
Inputs="$(MSBuildAllProjects)"
Outputs="$(NuSpecPath)"
DependsOnTargets="ConvertItems">
<GenerateNuSpec OutputFileName="$(NuSpecPath)"
Id="$(Id)"
Version="$(Version)"
Title="$(Title)"
Authors="$(Authors)"
Owners="$(Owners)"
Description="$(Description)"
ReleaseNotes="$(ReleaseNotes)"
Summary="$(Summary)"
Language="$(Language)"
ProjectUrl="$(ProjectUrl)"
IconUrl="$(IconUrl)"
LicenseUrl="$(LicenseUrl)"
Copyright="$(Copyright)"
RequireLicenseAcceptance="$(RequireLicenseAcceptance)"
Tags="$(Tags)"
Dependencies="@(Dependency)"
References="@(Reference)"
FrameworkReferences="@(FrameworkReference)"
Files="@(File)"/>
</Target>
<!--
CREATE PACKAGE
-->
<Target Name="CreatePackage"
Inputs="$(MSBuildAllProjects);
$(NuSpecPath);
@(File)"
Outputs="$(NuGetOuputPath)"
DependsOnTargets="GenerateNuSpec">
<MakeDir Directories="$(OutDir)"
Condition="!Exists('$(OutDir)')" />
<NuGetPack OutputDirectory="$(OutDir)"
ToolPath="$(NuGetToolPath)"
ToolExe="$(NuGetToolExe)"
NuSpecPath="$(NuSpecPath)"/>
</Target>
<!--
STANDARD BUILD TARGETS
-->
<Target Name="Clean">
<ItemGroup>
<_ToBeDeleted Include="$(NuSpecPath)" />
<_ToBeDeleted Include="$(NuGetOuputPath)" />
</ItemGroup>
<Delete Files="@(_ToBeDeleted)" />
</Target>
<Target Name="Build" DependsOnTargets="CreatePackage" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>

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

@ -0,0 +1,15 @@
<Project DefaultTargets="UnitTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildQuality Condition="'$(BuildQuality)' == ''">rtm</BuildQuality>
<VersionStartYear>2018</VersionStartYear>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionRelease>0</VersionRelease>
<VersionRelease Condition="'$(BuildQuality)' != 'rtm'">$(VersionRelease)-$(BuildQuality)</VersionRelease>
</PropertyGroup>
<PropertyGroup Label="NuGet package dependencies">
<UnityContainerNuGetPackageVersion>5.8.6</UnityContainerNuGetPackageVersion>
<WebActivatorExNuGetPackageVersion>2.2.0</WebActivatorExNuGetPackageVersion>
</PropertyGroup>
</Project>

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

@ -0,0 +1,23 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RepositoryRootEx Condition="'$(RepositoryRootEx)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebFormsDependencyInjection.sln))\</RepositoryRootEx>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<BinPath>$(RepositoryRootEx)bin\</BinPath>
<ObjPath>$(RepositoryRootEx)obj\</ObjPath>
<OutputPath>$(BinPath)$(Configuration)\</OutputPath>
<IntermediateOutputPath>$(ObjPath)$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<AssemblyPath Condition="'$(CodeSignEnabled)' == 'true'">$(CodeSignOutputPath)</AssemblyPath>
<AssemblyPath Condition="'$(AssemblyPath)' == ''">$(OutputPath)</AssemblyPath>
</PropertyGroup>
<PropertyGroup>
<CustomAfterProjectTargets>$(MSBuildThisFileDirectory)WebFormsDependencyInjection.Extensions.targets</CustomAfterProjectTargets>
</PropertyGroup>
</Project>

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

@ -0,0 +1,8 @@
<Project DefaultTargets="UnitTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Update NuGet Package version for nightly build-->
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.nuproj'">
<NuGetPackageVersion Condition="'$(UpdateNightlyPackages)' == 'true'">$(NuGetPackageVersion)-b$(VersionBuild)</NuGetPackageVersion>
</PropertyGroup>
</Project>

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

@ -0,0 +1,37 @@
<Project DefaultTargets="UnitTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CustomBeforeProjectTargets>$(MSBuildThisFileDirectory)WebFormsDependencyInjection.Extensions.settings.targets</CustomBeforeProjectTargets>
</PropertyGroup>
<Import Project="$(CustomBeforeProjectTargets)" Condition="Exists('$(CustomBeforeProjectTargets)')" Label="Pre-targets Build Extensibility Point"/>
<!-- Default properties -->
<PropertyGroup>
<RepositoryRoot Condition="'$(RepositoryRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), WebFormsDependencyInjection.sln))\</RepositoryRoot>
<SolutionDir>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), WebFormsDependencyInjection.sln))\</SolutionDir>
</PropertyGroup>
<PropertyGroup Label="Common Configuration">
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<OutputPath>$(RepositoryRoot)bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>$(RepositoryRoot)obj\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<AssemblyPath Condition="'$(AssemblyPath)' == ''">$(OutputPath)</AssemblyPath>
<NuGetOutputPath>$(AssemblyPath)Packages</NuGetOutputPath>
<NuGetSymbolsOutputPath>$(AssemblyPath)\SymbolPackages</NuGetSymbolsOutputPath>
<TestOutputPath>$(OutputPath)test\</TestOutputPath>
</PropertyGroup>
<PropertyGroup>
<ReferencePackagesPath>$(RepositoryRoot)packages\</ReferencePackagesPath>
<NuGetPackSymbols Condition="'$(NuGetPackSymbols)' == ''">true</NuGetPackSymbols>
<SourceRootFullPath>$(RepositoryRoot)\src\$(MSBuildProjectName)\</SourceRootFullPath>
</PropertyGroup>
<PropertyGroup>
<CustomAfterMicrosoftCommonTargets>$(RepositoryRoot)tools\WebFormsDependencyInjection.targets</CustomAfterMicrosoftCommonTargets>
<CustomAfterNuGetProjTargets>$(CustomAfterMicrosoftCommonTargets)</CustomAfterNuGetProjTargets>
</PropertyGroup>
</Project>

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

@ -0,0 +1,30 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Build order -->
<PropertyGroup>
<BuildDependsOn>SetNuSpecProperties;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)version.targets"/>
<!-- Post-targets computed properties. -->
<PropertyGroup>
<SatelliteContractVersion Condition="'$(SatelliteContractVersion)' == ''">$(AssemblyVersion)</SatelliteContractVersion>
</PropertyGroup>
<Import Project="$(CustomAfterProjectTargets)" Condition="Exists('$(CustomAfterProjectTargets)')" Label="Post-targets Build Extensibility Point" />
<!-- Target definitions -->
<Target Name="SetNuSpecProperties">
<PropertyGroup>
<NuSpecProperties>
NuGetPackageVersion=$(NuGetPackageVersion);
NuGetPackageId=$(NuGetPackageId);
UnityContainerNuGetPackageVersion=$(UnityContainerNuGetPackageVersion);
WebActivatorExNuGetPackageVersion=$(WebActivatorExNuGetPackageVersion);
</NuSpecProperties>
</PropertyGroup>
</Target>
</Project>

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

@ -0,0 +1,112 @@
<!--
****************************************************************************************************
Project global versioning targets.
****************************************************************************************************-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Input parameters -->
<!-- NOTE: The VersionFileAttribute ItemGroup can be used to add assembly-level attributes to the generated version file, ex:
<VersionFileAttribute Include="[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2243:AttributeStringLiteralsShouldParseCorrectly&quot;, Justification = &quot;Justification here&quot;)]" />
-->
<PropertyGroup>
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == '' AND '$(MSBuildProjectExtension)' == '.csproj'">true</VersionFileGenerationEnabled>
<VersionFileGenerationEnabled Condition="'$(VersionFileGenerationEnabled)' == ''">false</VersionFileGenerationEnabled>
</PropertyGroup>
<PropertyGroup>
<VersionStartYear Condition="'$(VersionStartYear)' == ''">2016</VersionStartYear>
<VersionMajor Condition="'$(VersionMajor)' == ''">INVALID_VersionMajor</VersionMajor>
<VersionMinor Condition="'$(VersionMinor)' == ''">INVALID_VersionMinor</VersionMinor>
<VersionBuild Condition="'$(VersionBuild)' == '' OR '$(VersionBuild)' == '0'">$([MSBuild]::Add(1, $([MSBuild]::Subtract($([System.DateTime]::Now.Year), $(VersionStartYear)))))$([System.DateTime]::Now.ToString("MMdd"))</VersionBuild>
<VersionRevision Condition="'$(VersionRevision)' == ''">0</VersionRevision>
<VersionRelease Condition="'$(VersionRelease)' == ''">0</VersionRelease>
</PropertyGroup>
<!-- Comptued parameters -->
<PropertyGroup>
<AssemblyVersion>$(VersionMajor).$(VersionMinor).0.$(VersionRevision)</AssemblyVersion>
<AssemblyFileVersion>$(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision)</AssemblyFileVersion>
<AssemblyInfoVersion Condition="'$(VersionRelease)' != ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)-$(VersionBuild)</AssemblyInfoVersion>
<AssemblyInfoVersion Condition="'$(AssemblyInfoVersion)' == ''">$(AssemblyFileVersion)</AssemblyInfoVersion>
<AssemblyVersionFile>$(IntermediateOutputPath)$(MSBuildProjectName).version.cs</AssemblyVersionFile>
</PropertyGroup>
<PropertyGroup>
<NuGetPackageVersion Condition="'$(NuGetPackageVersion)' == ''">$(VersionMajor).$(VersionMinor).$(VersionRelease)</NuGetPackageVersion>
</PropertyGroup>
<ItemGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
<Compile Include="$(AssemblyVersionFile)" />
</ItemGroup>
<ItemGroup>
<Clean Include="$(AssemblyVersionFile)" Condition="'$(MSBuildProjectExtension)' == '.csproj'"/>
</ItemGroup>
<PropertyGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
<!-- Disable assembly version defined in CommonAssemblyInfo.cs file -->
<DefineConstants>$(DefineConstants);BUILD_GENERATED_VERSION</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<!--Force a rebuild if this file is changed -->
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<!--
==================================================================================================
GenerateVersionFile target: generates assembly attributes into a source file that is included
in the items to compile.
================================================================================================== -->
<PropertyGroup Condition="'$(VersionFileGenerationEnabled)' == 'true'">
<CompileDependsOn>GenerateVersionFile;$(CompileDependsOn)</CompileDependsOn>
<GenerateVersionFileDependsOn>ValidateVersionValues;ShouldGenerateVersionFile;GenerateVersionFileCore</GenerateVersionFileDependsOn>
</PropertyGroup>
<Target Name="GenerateVersionFile" DependsOnTargets="$(GenerateVersionFileDependsOn)" />
<Target Name="GenerateVersionFileCore" Condition="'$(ShouldGenerateVersionFile)' == 'true'">
<ItemGroup>
<LinesToWrite Include="// $(SourceFileCopyright)" Condition="'$(SourceFileCopyright)' != ''"/>
<LinesToWrite Include="// &lt;auto-generated&gt;" />
<LinesToWrite Include="// This code was generated by a tool." />
<LinesToWrite Include="// &lt;/auto-generated&gt;" />
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCompany(&quot;$(AssemblyCompany)&quot;)]" Condition="'$(AssemblyCompany)' != ''"/>
<LinesToWrite Include="[assembly: System.Reflection.AssemblyCopyright(&quot;$(AssemblyCopyright)&quot;)]" Condition="'$(AssemblyCopyright)' != ''"/>
<LinesToWrite Include="[assembly: System.Reflection.AssemblyVersion(&quot;$(AssemblyVersion)&quot;)]" Condition="'$(AssemblyVersion)' != ''"/>
<LinesToWrite Include="[assembly: System.Reflection.AssemblyFileVersion(&quot;$(AssemblyFileVersion)&quot;)]" Condition="'$(AssemblyFileVersion)' != ''"/>
<LinesToWrite Include="[assembly: System.Reflection.AssemblyInformationalVersion(&quot;$(AssemblyInfoVersion)&quot;)]" Condition="'$(AssemblyInfoVersion)' != ''" />
<LinesToWrite Include="[assembly: System.Resources.SatelliteContractVersionAttribute(&quot;$(SatelliteContractVersion)&quot;)]" Condition="'$(SatelliteContractVersion)' != ''"/>
<LinesToWrite Include="@(VersionFileAttribute)" Condition="'@(VersionFileAttribute)' != ''" />
</ItemGroup>
<WriteLinesToFile File="$(AssemblyVersionFile)" Lines="@(LinesToWrite)" Overwrite="true" Encoding="Unicode"/>
<Message Text="Assembly Version File: $(AssemblyVersionFile)" />
</Target>
<!--
==================================================================================================
ShouldGenerateVersionFile target: determines whether a version needs to be generated.
================================================================================================== -->
<Target Name="ShouldGenerateVersionFile">
<ReadLinesFromFile File="$(AssemblyVersionFile)" Condition="Exists('$(AssemblyVersionFile)')">
<Output ItemName="VersionText" TaskParameter="Lines"/>
</ReadLinesFromFile>
<PropertyGroup>
<VersionText>@(VersionText)</VersionText>
<ShouldGenerateVersionFile>!$(VersionText.Contains('$(AssemblyFileVersion)'))</ShouldGenerateVersionFile>
</PropertyGroup>
</Target>
<Target Name="ValidateVersionValues">
<!-- Throw if any of the version values is not int16 -->
<PropertyGroup>
<VersionMajor>$([System.Convert]::ToInt16('$(VersionMajor)'))</VersionMajor>
<VersionMinor>$([System.Convert]::ToInt16('$(VersionMinor)'))</VersionMinor>
<VersionBuild>$([System.Convert]::ToInt16('$(VersionBuild)'))</VersionBuild>
<VersionRevision>$([System.Convert]::ToInt16('$(VersionRevision)'))</VersionRevision>
</PropertyGroup>
</Target>
</Project>