Skip to content

Commit

Permalink
Merge pull request #56 from ermshiperete/feature/nuget
Browse files Browse the repository at this point in the history
Create nuget package
  • Loading branch information
andrew-polk authored Apr 16, 2019
2 parents a8caae8 + 16eda60 commit 8371fb2
Show file tree
Hide file tree
Showing 28 changed files with 667 additions and 796 deletions.
9 changes: 7 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ insert_final_newline = true
charset = utf-8
indent_size = 4

[*.{cs,csproj,sln}]
[*.cs]
indent_style = tab

# Settings Visual Studio uses for generated files
[*.{csproj,resx,settings,vcxproj*,vdproj,xml}]
indent_style = space
indent_size = 2

[*.pug]
indent_style = tab

[*.{ts,json,js,md,jsx,css,less}]
indent_style = space

[*.tmx]
[*.{tmx,yml}]
indent_style = space
indent_size = 2

Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
*.patch -whitespace
*.svg -whitespace
*.xml -whitespace
*.yml -whitespace
changelog -whitespace
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

_ReSharper*
.idea/
.vs/
output/
obj/
*.suo
Expand All @@ -8,8 +10,9 @@ L10NSharp.userprefs
bin/
*.ncrunchsolution
*Copy*.bat
*.userprefs

*.bak
packages/
build/NuGet.exe
/.vs/
build/nuget.exe
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

<!-- Available types of changes:
### Added
### Changed
### Fixed
### Deprecated
### Removed
### Security
-->

## [Unreleased]

### Changed

- Create nuget package
- Strong-name assembly
21 changes: 21 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
assembly-versioning-scheme: MajorMinor
mode: ContinuousDeployment
next-version: 3.1.0
tag-prefix: xliff-
branches:
master:
tag: beta
regex: (origin/)?(master|xliff)
hotfix:
tag: beta
regex: (origin/)?hotfix[/-]
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
pull-request:
mode: ContinuousDeployment
tag: PR
ignore:
sha: []
29 changes: 25 additions & 4 deletions L10NSharp.sln
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.28307.438
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L10NSharp", "src\L10NSharp\L10NSharp.csproj", "{8EE0895A-7B9D-4B49-8F73-9F1270F1E583}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "L10NSharp", "src\L10NSharp\L10NSharp.csproj", "{8EE0895A-7B9D-4B49-8F73-9F1270F1E583}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L10NSharpTests", "src\L10NSharpTests\L10NSharpTests.csproj", "{BCE5B569-057C-4D7E-832E-E44A2DA705AC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "L10NSharpTests", "src\L10NSharpTests\L10NSharpTests.csproj", "{BCE5B569-057C-4D7E-832E-E44A2DA705AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "src\SampleApp\SampleApp.csproj", "{58923B30-FD84-4BCC-85E0-607DCA7E7C95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtractXliff", "src\ExtractXliff\ExtractXliff.csproj", "{E0666C78-B8DC-4232-952C-753940D54921}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckOrFixXliff", "src\CheckOrFixXliff\CheckOrFixXliff.csproj", "{E4BB984D-DFB8-42EF-860D-5A038FF85B1C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder", "SolutionFolder", "{7BE95674-0B77-4BA4-9A8A-57718D2B196C}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
GitVersion.yml = GitVersion.yml
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L10NSharp-Designer", "src\L10NSharp\L10NSharp-Designer.csproj", "{91806E96-1F40-46DF-AEC9-0095D695E5EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -76,8 +88,17 @@ Global
{E4BB984D-DFB8-42EF-860D-5A038FF85B1C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E4BB984D-DFB8-42EF-860D-5A038FF85B1C}.Release|x86.ActiveCfg = Release|Any CPU
{E4BB984D-DFB8-42EF-860D-5A038FF85B1C}.Release|x86.Build.0 = Release|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Debug|x86.ActiveCfg = Debug|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{91806E96-1F40-46DF-AEC9-0095D695E5EE}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C94DFCDA-FC93-4E55-BA2C-E15D8057AC7A}
EndGlobalSection
EndGlobal
Binary file added L10NSharp.snk
Binary file not shown.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

L10NSharp is a .NET localization library for Windows Forms applications. It collects strings which needs localization when your application first runs and saves them in a Translation Memory eXchange (TMX) file. It can also dynamically collect strings at runtime.

The `master` branch works with TMX files, the `xliff` branch with XLIFF files as translation memory.

## L10NSharpExtender

To localize a Windows Forms form or control, simply add the L10NSharpExtender. It will automatically collect all the localizable strings on your form or control and its children.
To localize a Windows Forms form or control, simply add the `L10NSharpExtender`. It will automatically collect all the localizable strings on your form or control and its children.

## Localizing Within the Application

Expand All @@ -14,18 +16,24 @@ L10NSharp provides a dialog for translating terms while running the application.

Just download the repository and build the solution (L10NSharp.sln).

For Linux, the build command would look something like this:
The command line build command would look something like this:

/opt/mono4-sil/bin/xbuild build/L10NSharp.proj /t:Build /p:Configuration=Debug
msbuild /t:Build /p:Configuration=Debug build/L10NSharp.proj

Note that building L10NSharp requires at least version 4.6 of Mono, which mono4-sil provides.
Note that on Linux building L10NSharp requires at least version 5 of Mono, which mono5-sil provides. The mono 5 version that the Mono project provides also works (if mono is at least version 5.16).

## Running Unit Tests

We use NUnit to run our unit tests. NUnit is downloaded via NuGet. There may be a few tests that do not run, but all tests that run should pass.

For Linux, the command to run the tests would look something like this:
The tests can be run from the command line like this:

msbuild /t:Test build/L10NSharp.proj

It is also possible to run the tests from inside Visual Studio, Rider or MonoDevelop (if mono5-sil is installed and made the default Mono runtime).

/opt/mono4-sil/bin/mono packages/NUnit.Runners.Net4.2.6.4/tools/nunit-console.exe output/Debug/L10NSharpTests.dll
## Working on UI related files

It is also possible to run the tests from inside MonoDevelop, at least if mono4-sil is installed and made the default Mono runtime.
The L10NSharp project uses SDK style .csproj files which don't allow the Designer to be used in Visual Studio 2017.
There is a `src\L10NSharp\L10NSharp-Designer.csproj` file which uses the old .csproj style and thus allows the
programmer to edit the files with the Designer in Visual Studio 2017.
69 changes: 52 additions & 17 deletions build/L10NSharp.proj
Original file line number Diff line number Diff line change
@@ -1,40 +1,75 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Pack">
<PropertyGroup>
<RootDir Condition="'$(teamcity_version)' == '' Or '$(OS)'!='Windows_NT'">$(MSBuildProjectDirectory)\..</RootDir>
<RootDir Condition="'$(teamcity_version)' != '' And '$(OS)'=='Windows_NT'">$(teamcity_build_checkoutDir)</RootDir>
<Solution>L10NSharp.sln</Solution>
<Configuration>Release</Configuration>
<teamcity_agent_home_dir Condition="'$(teamcity_agent_home_dir)'=='' And '$(OS)'!='Windows_NT'">/var/lib/TeamCity/agent</teamcity_agent_home_dir>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<RestartBuild Condition="!Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')">true</RestartBuild>
<RestartBuild Condition="Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')">false</RestartBuild>
<useNUnit-x86 Condition="'$(OS)'=='Windows_NT'">true</useNUnit-x86>
<useNUnit-x86 Condition="'$(OS)'!='Windows_NT'">false</useNUnit-x86>
<ExtraExcludeCategories Condition="'$(OS)'!='Windows_NT'">KnownMonoIssue,</ExtraExcludeCategories>
<ExtraExcludeCategories Condition="'$(teamcity_version)' != ''">SkipOnTeamCity,$(ExtraExcludeCategories)</ExtraExcludeCategories>
</PropertyGroup>

<UsingTask TaskName="NUnitTeamCity"
AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"
Condition=" '$(teamcity_version)' != '' And '$(OS)'=='Windows_NT'"/>
<UsingTask TaskName="NUnitTeamCity"
AssemblyFile="$(agent_home_dir)/plugins/dotnetPlugin/bin/JetBrains.BuildServer.MSBuildLoggers.dll"
Condition=" '$(teamcity_version)' != '' And '$(OS)'!='Windows_NT'"/>
<UsingTask TaskName="NUnit" AssemblyFile="$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll"
Condition="Exists('$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll')"/>

<Import Project="NuGet.targets"/>

<Target Name="Build" DependsOnTargets="RestorePackages">
<Target Name="Build">
<CallTarget Targets="RestoreBuildTasks" />
<CallTarget Targets="BuildInternal" Condition="!$(RestartBuild)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="BuildInternal"
Properties="Configuration=$(Configuration);RootDir=$(RootDir)"
Condition="$(RestartBuild)" />
</Target>

<Target Name="BuildInternal" DependsOnTargets="RestorePackages">
<MSBuild Projects="$(RootDir)/$(Solution)"
Targets="Rebuild"
Targets="Restore;Rebuild"
Properties="Configuration=$(Configuration)" />
</Target>

<Target Name="RestoreBuildTasks" DependsOnTargets="CheckPrerequisites">
<Message Text="RestartBuild=$(RestartBuild)" />
<Exec Command='$(NuGetCommand) install NUnit.Runners.Net4 -version 2.6.4 -solutionDirectory "$(RootDir)"' />
<Exec Command='$(NuGetCommand) install SIL.BuildTasks -excludeVersion -version 2.2.0 -solutionDirectory "$(RootDir)"' />
</Target>

<Target Name="Pack" DependsOnTargets="Build">
<MSBuild Projects="$(RootDir)/src/L10NSharp/L10NSharp.csproj"
Targets="Pack"
Properties="Configuration=$(Configuration)" />
</Target>

<Target Name="Test" DependsOnTargets="Build">
<CallTarget Targets="TestOnly"/>
<CallTarget Targets="TestOnly" Condition="!$(RestartBuild)" />
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="TestOnly"
Properties="Configuration=$(Configuration);RootDir=$(RootDir);Platform=$(Platform)"
Condition="$(RestartBuild)" />
</Target>


<Target Name="TestOnly">
<PropertyGroup>
<NUnitVersion>2.6.4</NUnitVersion>
<NUnitRunnerPackage>$(RootDir)/packages/NUnit.Runners.Net4.$(NUnitVersion)</NUnitRunnerPackage>
</PropertyGroup>
<ItemGroup>
<TestAssemblies Include="$(RootDir)/output/$(Configuration)/L10NSharpTests.dll"/>
<TestAssemblies Include="$(RootDir)/output/$(Configuration)/net461/L10NSharpTests.dll"/>
</ItemGroup>

<NUnitTeamCity
Assemblies="@(TestAssemblies)"
ExcludeCategory="SkipOnTeamCity"
NUnitVersion="NUnit-2.6.3" />
<NUnit Assemblies="@(TestAssemblies)"
ToolPath="$(NUnitRunnerPackage)/tools"
TestInNewThread="false"
ExcludeCategory="$(ExtraExcludeCategories)$(excludedCategories)"
WorkingDirectory="$(RootDir)/output/$(Configuration)/net461"
Force32Bit="$(useNUnit-x86)"
Verbose="true"
OutputXmlFile="$(RootDir)/output/$(Configuration)/net461/TestResults.xml"/>
<Message Text="##teamcity[importData type='nunit' path='$(RootDir)/output/$(Configuration)/net461/TestResults.xml']"
Condition="'$(teamcity_version)' != ''"/>
</Target>

</Project>
19 changes: 9 additions & 10 deletions build/NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. -->
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="http://build.palaso.org/guestAuth/app/nuget/v1/FeedService.svc/" />
<PackageSource Include="https://build.palaso.org/guestAuth/app/nuget/v1/FeedService.svc/" />
</ItemGroup>

<PropertyGroup>
<NuGetToolsPath>$(MSBuildThisFileDirectory)</NuGetToolsPath>
<PackagesConfig>$(ProjectDir)packages.config</PackagesConfig>
<PackagesConfig Condition="'$(PackagesConfig)'=='' AND '$(OS)'=='Windows_NT'">$(ProjectDir)packages.config</PackagesConfig>
<PackagesConfig Condition="'$(PackagesConfig)'=='' AND '$(OS)'!='Windows_NT'">$(ProjectDir)/packages.config</PackagesConfig>

<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)/NuGet.exe</NuGetExePath>
<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>
<NuGetDownloadUrl>https://dist.nuget.org/win-x86-commandline/latest/nuget.exe</NuGetDownloadUrl>
</PropertyGroup>

<Target Name="CheckPrerequisites">
Expand All @@ -49,7 +51,7 @@
<Target Name="_DownloadNuGet" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')">
<DownloadNuGet OutputFilename="$(NuGetExePath)"
Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="wget https://nuget.org/NuGet.exe || curl -O -L https://nuget.org/NuGet.exe"
<Exec Command="wget $(NuGetDownloadUrl) || curl -O -L $(NuGetDownloadUrl)"
WorkingDirectory="$(NuGetToolsPath)"
Condition="'$(OS)' != 'Windows_NT'" />
</Target>
Expand All @@ -59,10 +61,7 @@
</ItemGroup>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command='$(NuGetCommand) restore -source "$(PackageSources)" "$(SolutionPath)"'
Condition="Exists('$(SolutionPath)')"/>
<Exec Command='$(NuGetCommand) restore -source "$(PackageSources)" -SolutionDirectory "$(SolutionDir)" "%(PackageConfigs.FullPath)"'
Condition="!Exists('$(SolutionPath)')"/>
<Exec Command='$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDirectory "$(SolutionDir)."'/>
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory"
Expand All @@ -85,7 +84,7 @@
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/NuGet.exe", OutputFilename);
webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", OutputFilename);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion environ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
MONO_PREFIX=/opt/mono4-sil
MONO_PREFIX=/opt/mono5-sil
export DYLD_LIBRARY_FALLBACK_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_FALLBACK_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include
Expand Down
Loading

0 comments on commit 8371fb2

Please sign in to comment.