Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving build task into separate project

The assembly kept getting locked preventing me from rebuilding. Now when you run package.cmd, it will run the custom MSBuild task and create a computed nuspec file
  • Loading branch information...
commit 318d543e415666fb796285fd5228d816148f3ab3 1 parent a7bbb3a
@pseudomuto pseudomuto authored
View
BIN  .nuget/RestSharp.Build.dll
Binary file not shown
View
17 RestSharp/Automation/NuSpecUpdateTask.cs → RestSharp.Build/NuSpecUpdateTask.cs
@@ -5,8 +5,9 @@
using Microsoft.Build.Utilities;
using System.Reflection;
using System.Xml.Linq;
+using System.IO;
-namespace RestSharp.Automation
+namespace RestSharp.Build
{
public class NuSpecUpdateTask : Task
{
@@ -22,6 +23,8 @@ public class NuSpecUpdateTask : Task
public string SpecFile { get; set; }
+ public string SourceAssemblyFile { get; set; }
+
public NuSpecUpdateTask()
: this(null)
{
@@ -29,14 +32,16 @@ public NuSpecUpdateTask()
public NuSpecUpdateTask(Assembly assembly)
{
- this._assembly = assembly ??
- Assembly.GetExecutingAssembly();
+ this._assembly = assembly;
}
public override bool Execute()
{
if (string.IsNullOrEmpty(this.SpecFile)) return false;
+ var path = Path.GetFullPath(this.SourceAssemblyFile);
+ this._assembly = this._assembly ?? Assembly.LoadFile(path);
+
var name = this._assembly.GetName();
this.Id = name.Name;
@@ -44,8 +49,8 @@ public override bool Execute()
this.Description = this.GetDescription(this._assembly);
this.Version = this.GetVersion(this._assembly);
- this.GenerateComputedSpecFile();
-
+ this.GenerateComputedSpecFile();
+
return true;
}
@@ -112,6 +117,6 @@ private string GetVersion(Assembly asm)
}
return null;
- }
+ }
}
}
View
36 RestSharp.Build/Properties/AssemblyInfo.cs
@@ -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("RestSharp.Build")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RestSharp.Build")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[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("1cf9b3e7-67bb-4dca-9094-5f8c94ef9587")]
+
+// 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")]
View
55 RestSharp.Build/RestSharp.Build.csproj
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RestSharp.Build</RootNamespace>
+ <AssemblyName>RestSharp.Build</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="Microsoft.Build.Framework" />
+ <Reference Include="Microsoft.Build.Utilities.v3.5" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="NuSpecUpdateTask.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
8 RestSharp.Tests/NuSpecUpdateTask.cs
@@ -36,7 +36,7 @@ public class WhenSpecFileNotSpecified
[Fact]
public void ReturnsFalse()
{
- var task = new Automation.NuSpecUpdateTask();
+ var task = new Build.NuSpecUpdateTask();
Assert.False(task.Execute());
}
}
@@ -48,8 +48,9 @@ public class WhenInformationalVersionIsNotDefined : BaseNuSpecUpdateTest
[Fact]
public void PullsVersionAttributeInstead()
{
- var task = new Automation.NuSpecUpdateTask(this.GetType().Assembly);
+ var task = new Build.NuSpecUpdateTask();
task.SpecFile = this.FileName;
+ task.SourceAssemblyFile = "RestSharp.Tests.dll";
task.Execute();
Assert.Equal("1.0.0.0", task.Version);
@@ -58,7 +59,7 @@ public void PullsVersionAttributeInstead()
public class WhenSpecFileIsValid : BaseNuSpecUpdateTest
{
- private Automation.NuSpecUpdateTask _subject = new Automation.NuSpecUpdateTask();
+ private Build.NuSpecUpdateTask _subject = new Build.NuSpecUpdateTask();
private bool _result;
private string _expectedId = "RestSharp";
@@ -70,6 +71,7 @@ public class WhenSpecFileIsValid : BaseNuSpecUpdateTest
protected override void Setup()
{
this._subject.SpecFile = this.FileName;
+ this._subject.SourceAssemblyFile = "RestSharp.dll";
this._result = this._subject.Execute();
}
View
4 RestSharp.Tests/RestSharp.Tests.csproj
@@ -200,6 +200,10 @@
</Target>
-->
<ItemGroup>
+ <ProjectReference Include="..\RestSharp.Build\RestSharp.Build.csproj">
+ <Project>{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}</Project>
+ <Name>RestSharp.Build</Name>
+ </ProjectReference>
<ProjectReference Include="..\RestSharp\RestSharp.csproj">
<Project>{2ECECFBF-5F3E-40EE-A963-72336DC7ABE2}</Project>
<Name>RestSharp</Name>
View
12 RestSharp.sln
@@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1B3F12
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{EED2643E-915D-4024-A588-5EBDF795019D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Build", "RestSharp.Build\RestSharp.Build.csproj", "{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -98,6 +98,16 @@ Global
{5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|x86.ActiveCfg = Release|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {CCC30138-3D68-44D8-AF1A-D22F769EE8DC}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
8 RestSharp/RestSharp.csproj
@@ -94,7 +94,6 @@
<Compile Include="Authenticators\OAuth\WebPairCollection.cs" />
<Compile Include="Authenticators\OAuth\WebParameter.cs" />
<Compile Include="Authenticators\OAuth\WebParameterCollection.cs" />
- <Compile Include="Automation\NuSpecUpdateTask.cs" />
<Compile Include="Compression\ZLib\Crc32.cs" />
<Compile Include="Compression\ZLib\FlushType.cs" />
<Compile Include="Compression\ZLib\GZipStream.cs" />
@@ -183,7 +182,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
- <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<PropertyGroup>
@@ -197,8 +195,8 @@
<Target Name="AfterBuild">
</Target>
-->
- <UsingTask TaskName="NuSpecUpdateTask" AssemblyFile="$(OutDir)RestSharp.dll" />
- <Target Name="AfterBuild">
- <NuSpecUpdateTask SpecFile="$(SolutionDir)restsharp.nuspec" />
+ <UsingTask TaskName="NuSpecUpdateTask" AssemblyFile="$(SolutionDir).nuget\RestSharp.Build.dll" />
+ <Target Name="AfterBuild" Condition="$(Configuration) == Release">
+ <NuSpecUpdateTask SpecFile="$(SolutionDir)restsharp.nuspec" SourceAssemblyFile="$(TargetDir)RestSharp.dll" />
</Target>
</Project>
View
BIN  Tools/NuGet.exe
Binary file not shown
View
3  package.cmd
@@ -45,4 +45,5 @@ copy RestSharp.Silverlight\bin\Release\RestSharp.Silverlight.xml Download\Packag
copy RestSharp.WindowsPhone\bin\Release\RestSharp.WindowsPhone.xml Download\Package\lib\sl4-wp71\
tools\nuget.exe update -self
-tools\nuget.exe pack restsharp.nuspec -BasePath Download\Package -Output Download
+tools\nuget.exe pack restsharp-computed.nuspec -BasePath Download\Package -Output Download
+rm restsharp-computed.nuspec
Please sign in to comment.
Something went wrong with that request. Please try again.