Skip to content

Commit b5fa372

Browse files
committed
Add nuget metadata and publish script
1 parent 193f6e8 commit b5fa372

9 files changed

+208
-12
lines changed

.nuget/NuGet.Config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.targets

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Enable the restore command to run before builds -->
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
8+
9+
<!-- Property that enables building a package from a project -->
10+
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11+
12+
<!-- Determines if package restore consent is required to restore packages -->
13+
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
14+
15+
<!-- Download NuGet.exe if it does not already exist -->
16+
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
17+
</PropertyGroup>
18+
19+
<ItemGroup Condition=" '$(PackageSources)' == '' ">
20+
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21+
<!-- 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 -->
22+
<!--
23+
<PackageSource Include="https://www.nuget.org/api/v2/" />
24+
<PackageSource Include="https://my-nuget-source/nuget/" />
25+
-->
26+
</ItemGroup>
27+
28+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
29+
<!-- Windows specific commands -->
30+
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
34+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
35+
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
36+
</PropertyGroup>
37+
38+
<PropertyGroup>
39+
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
40+
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
41+
</PropertyGroup>
42+
43+
<PropertyGroup>
44+
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
45+
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
46+
</PropertyGroup>
47+
48+
<PropertyGroup>
49+
<!-- NuGet command -->
50+
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
51+
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
52+
53+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
54+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
55+
56+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
57+
58+
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
59+
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
60+
61+
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
62+
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
63+
64+
<!-- Commands -->
65+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
66+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
67+
68+
<!-- We need to ensure packages are restored prior to assembly resolve -->
69+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
70+
RestorePackages;
71+
$(BuildDependsOn);
72+
</BuildDependsOn>
73+
74+
<!-- Make the build depend on restore packages -->
75+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
76+
$(BuildDependsOn);
77+
BuildPackage;
78+
</BuildDependsOn>
79+
</PropertyGroup>
80+
81+
<Target Name="CheckPrerequisites">
82+
<!-- Raise an error if we're unable to locate nuget.exe -->
83+
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
84+
<!--
85+
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
86+
This effectively acts as a lock that makes sure that the download operation will only happen once and all
87+
parallel builds will have to wait for it to complete.
88+
-->
89+
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
90+
</Target>
91+
92+
<Target Name="_DownloadNuGet">
93+
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
94+
</Target>
95+
96+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
97+
<Exec Command="$(RestoreCommand)"
98+
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
99+
100+
<Exec Command="$(RestoreCommand)"
101+
LogStandardErrorAsError="true"
102+
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
103+
</Target>
104+
105+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
106+
<Exec Command="$(BuildCommand)"
107+
Condition=" '$(OS)' != 'Windows_NT' " />
108+
109+
<Exec Command="$(BuildCommand)"
110+
LogStandardErrorAsError="true"
111+
Condition=" '$(OS)' == 'Windows_NT' " />
112+
</Target>
113+
114+
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
115+
<ParameterGroup>
116+
<OutputFilename ParameterType="System.String" Required="true" />
117+
</ParameterGroup>
118+
<Task>
119+
<Reference Include="System.Core" />
120+
<Using Namespace="System" />
121+
<Using Namespace="System.IO" />
122+
<Using Namespace="System.Net" />
123+
<Using Namespace="Microsoft.Build.Framework" />
124+
<Using Namespace="Microsoft.Build.Utilities" />
125+
<Code Type="Fragment" Language="cs">
126+
<![CDATA[
127+
try {
128+
OutputFilename = Path.GetFullPath(OutputFilename);
129+
130+
Log.LogMessage("Downloading latest version of NuGet.exe...");
131+
WebClient webClient = new WebClient();
132+
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
133+
134+
return true;
135+
}
136+
catch (Exception ex) {
137+
Log.LogErrorFromException(ex);
138+
return false;
139+
}
140+
]]>
141+
</Code>
142+
</Task>
143+
</UsingTask>
144+
</Project>

FSharpLu.Tests/FSharpLu.Tests.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<OutputType>Library</OutputType>
1010
<RootNamespace>FSharpLu.Tests</RootNamespace>
1111
<AssemblyName>FSharpLu.Tests</AssemblyName>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1313
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1515
<Name>FSharpLu.Tests</Name>

FSharpLu.sln

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22823.1
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpLu", "src\FSharpLu.fsproj", "{77C664BE-DD18-476D-AB71-1144107DE408}"
77
EndProject
88
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpLu.Tests", "FSharpLu.Tests\FSharpLu.Tests.fsproj", "{1A22180F-57C3-4415-8D1A-4AD523967251}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1FF1118A-322F-4F49-AF9A-ED825DE70260}"
11+
ProjectSection(SolutionItems) = preProject
12+
src\FSharpLu.nuspec = src\FSharpLu.nuspec
13+
src\pushnuget.ps1 = src\pushnuget.ps1
14+
README.md = README.md
15+
EndProjectSection
16+
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{EE6A3D9E-8362-442B-9C8F-252B3ED7D8E4}"
18+
ProjectSection(SolutionItems) = preProject
19+
.nuget\NuGet.Config = .nuget\NuGet.Config
20+
.nuget\NuGet.exe = .nuget\NuGet.exe
21+
.nuget\NuGet.targets = .nuget\NuGet.targets
22+
EndProjectSection
23+
EndProject
1024
Global
1125
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1226
Debug|Any CPU = Debug|Any CPU

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# FSharpLu
22

3-
F# helpers for string manipulations, logging and collection data structures.
4-
3+
F# helpers for string manipulations, logging, collection data structures,
4+
file operations, text processing, security, async, parsing, diagnostics,
5+
configuration files.
56

67
## Contact
7-
william.blum@microsoft.OM
8+
william.blum@microsoft.com

src/AssemblyInfo.fs

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,4 @@ by using the '*' as shown below:
3636
[<assembly: AssemblyVersion("1.0.*")>] *)
3737
[<assembly: AssemblyVersion("0.9.*")>]
3838
[<assembly: AssemblyFileVersion("0.9.*")>]
39-
40-
do
41-
()
39+
()

src/FSharpLu.fsproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
<DocumentationFile>bin\Release\FSharpLu.XML</DocumentationFile>
3535
</PropertyGroup>
3636
<PropertyGroup>
37-
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
37+
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">12</MinimumVisualStudioVersion>
38+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == '11.0'">12.0</VisualStudioVersion>
3839
</PropertyGroup>
3940
<Choose>
4041
<When Condition="'$(VisualStudioVersion)' == '11.0'">
@@ -48,9 +49,8 @@
4849
</PropertyGroup>
4950
</Otherwise>
5051
</Choose>
51-
<Import Project="$(FSharpTargetsPath)" />
52+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets" />
5253
<ItemGroup>
53-
<Compile Include="AssemblyInfo.fs" />
5454
<Compile Include="Logging.fs" />
5555
<Compile Include="Text.fs" />
5656
<Compile Include="Collections.fs" />
@@ -60,6 +60,7 @@
6060
<Compile Include="Diagnostics.fs" />
6161
<Compile Include="Security.fs" />
6262
<Compile Include="Parsing.fs" />
63+
<Compile Include="AssemblyInfo.fs" />
6364
</ItemGroup>
6465
<ItemGroup>
6566
<Reference Include="mscorlib" />

src/FSharpLu.nuspec

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>Microsoft.FSharpLu</id>
5+
<version>$version$</version>
6+
<title>$title$</title>
7+
<authors>wiblum</authors>
8+
<owners>wiblum</owners>
9+
<projectUrl>https://FSharpLu</projectUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>Utilities and .Net library wrappers for F#</description>
12+
<releaseNotes>Fix leak in atomicFileWrite.</releaseNotes>
13+
<copyright>Copyright 2015</copyright>
14+
<tags>F#, FSharp, FSharp utilities, collection, logging, diagnostic, async</tags>
15+
</metadata>
16+
</package>

src/pushnuget.ps1

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# pack with:
2+
param($nugetFeed)
3+
4+
$root = Split-Path -parent $psScriptRoot
5+
pushd $root
6+
$nuget = "$root\.nuget\nuget.exe"
7+
$msbuild = "${env:ProgramFiles(x86)}\\MSBuild\12.0\Bin\amd64\msbuild.exe"
8+
9+
& $msbuild $root\FSharpLu.sln /p:Configuration=Release /p:Platform="Any CPU"
10+
& $nuget pack $root\src\FSharpLu.fsproj -Prop Configuration=Release
11+
12+
if ($nugetFeed) {
13+
& $nuget push -Source $nugetFeed *.nupkg
14+
}
15+
16+
popd

0 commit comments

Comments
 (0)