Skip to content

Commit

Permalink
adding a very first version of build script + some VS template files
Browse files Browse the repository at this point in the history
  • Loading branch information
salaros committed Jul 16, 2018
1 parent 600b460 commit a4594e7
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,7 @@ __pycache__/

# Not sure why, but ASoft .NET Version Detector's reports
# keep bloating the project, so the rule below get's rid of them
--version*
--version*

# Exclude dist folder
dist/
5 changes: 5 additions & 0 deletions RevitAddin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
src\__TemplateIcon.ico = src\__TemplateIcon.ico
appveyor.yml = appveyor.yml
build.ps1 = build.ps1
global.json = global.json
LICENSE = LICENSE
README.md = README.md
src\RevitAddin.vstemplate = src\RevitAddin.vstemplate
EndProjectSection
EndProject
Global
Expand Down
109 changes: 109 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Operating system (build VM template)
os: Windows Server 2016

# If the build configuration does not specify build worker image
# then Visual Studio 2015 image is used.
image: Visual Studio 2017

# Restrict to Git branches below
branches:
only:
- master

environment:
VERSION_SIMPLE: '{version}'
VERSION_INFORMATIONAL: '{version}'
VERSION_UNSTABLE_SUFFIX: 'preview'
APPVEYOR_TOKEN:
secure: LtoVAPATN9iTCl1zkCvEktqP92QSEEngyS3vqG3GphE=

init:
- ps: |
$env:VERSION_SIMPLE = $env:APPVEYOR_BUILD_VERSION.TrimStart("v")
$env:VERSION_INFORMATIONAL = "$env:VERSION_SIMPLE"
$env:GITHUB_REPO_API = "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/tags"
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
### CHECK IF A IT'S A TAGGED BUILD
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
Write-Host "Building a tagged Git commit: $git_current_tag";
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $tag_ver.Major, $tag_ver.Minor, $tag_ver.Build
$env:VERSION_SIMPLE = "$env:VERSION_INFORMATIONAL.$env:APPVEYOR_BUILD_NUMBER"
}
} elseif ($env:VERSION_INFORMATIONAL -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$current_ver = [version]$env:VERSION_INFORMATIONAL
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $current_ver.Major, $current_ver.Minor, $current_ver.Build
$env:VERSION_INFORMATIONAL = "{0}-{1}{2}" -f $env:VERSION_INFORMATIONAL, $env:VERSION_UNSTABLE_SUFFIX, $env:APPVEYOR_BUILD_NUMBER
}
### MAKE CALCULATED INFORMATIONAL VERSION THE ACTUAL BUILD VERSION
Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL
Write-Host "Using build version: $env:VERSION_SIMPLE"
Write-Host "Using (informational) build version: $env:VERSION_INFORMATIONAL"
dotnet_csproj:
patch: true
file: '**\*.csproj'
assembly_version: $(VERSION_SIMPLE)
file_version: $(VERSION_SIMPLE)
version: $(VERSION_INFORMATIONAL)
package_version: $(VERSION_INFORMATIONAL)
informational_version: $(VERSION_INFORMATIONAL)

# Scripts that run after cloning repository
install:
- dotnet restore

# Run scripts below before
before_build:
- where msbuild
- cmd: msbuild /t:Clean

# To run your custom scripts instead of automatic MSBuild
build_script:
- cmd: msbuild /t:Rebuild
- ps: .\build.ps1

after_build:
- cmd: 7z a RevitAddin_2014-2019.zip %APPVEYOR_BUILD_FOLDER%\dist\*.*
- cmd: 7z a RevitAddin_2014-2019.zip %APPVEYOR_BUILD_FOLDER%\dist\**\*.*

artifacts:
- path: RevitAddin_2014-2019.zip
name: RevitAddin

after_deploy:
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
$apiUrl = 'https://ci.appveyor.com/api'
$headers = @{
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
"Content-type" = "application/json"
}
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body '{"nextBuildNumber": 1 }' -Headers $headers
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$ver_format = "version: {0}.{1}.{2}.{3}" -f $tag_ver.Major, $tag_ver.Minor, ($tag_ver.Build + 1), '{build}'
$headers."Content-type" = "text/plain";
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/yaml" -Body $ver_format -Headers $headers
}
}
# Deploy to GitHub releases
deploy:
-
provider: GitHub
auth_token:
secure: 2+d0KgCbWQpUR8TZfzvUEzbi4NQP6F/Tt0PUwLn6jXZCyO8FnrFVFJPsFa0QBQFl
artifact: RevitAddin
draft: false
force_update: true
prerelease: false
release: "Revit 2014-2019 C# Addin Template fro Visual Studio v$(APPVEYOR_REPO_TAG_NAME)"
tag: $(APPVEYOR_REPO_TAG_NAME)
on:
appveyor_repo_tag: true
17 changes: 17 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Requires -Version 3

# Process source files
$srcFiles = Get-ChildItem -Recurse .\src\* -Include *.cs*, *.addin | Where-Object {$_.FullName -NotMatch "\\obj\\"}
foreach ($file in $srcFiles) {
$outfile = ($file | Resolve-Path -Relative).Replace('\src\', '\dist\')
New-Item -ItemType Directory -Force -Path (Split-Path -Path $outfile -Parent) | Out-Null
(Get-Content $file).replace('RevitAddin', '$safeprojectname$') | Set-Content $outfile
}

# Copy static files
$staticFiles = Get-ChildItem -Recurse .\src\* -Include *.resx*, *.png, *.vstemplate, *.ico, *.json | Where-Object {$_.FullName -NotMatch "\\obj\\"}
foreach ($file in $staticFiles) {
$outfile = ($file | Resolve-Path -Relative).Replace('\src\', '\dist\')
New-Item -ItemType Directory -Force -Path (Split-Path -Path $outfile -Parent) | Out-Null
Copy-Item -Path $file -Destination $outfile
}
9 changes: 9 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"projects": [
"src",
"tests"
],
"sdk": {
"version": "2.1.301"
}
}
38 changes: 38 additions & 0 deletions src/RevitAddin.vstemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>Revit 2014-2019 C# Addin</Name>
<Description>Class library template for a Revit 2014-2019 C# .NET add-in project</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>RevitAddin</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<CreateInPlace>true</CreateInPlace>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<Project TargetFileName="RevitAddin.csproj" File="RevitAddin.csproj" ReplaceParameters="true">
<Folder Name="Properties" TargetFolderName="Properties">
<ProjectItem ReplaceParameters="true" TargetFileName="launchSettings.json">launchSettings.json</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Resources.resx">Resources.resx</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Resources.ru-RU.resx">Resources.ru-RU.resx</ProjectItem>
</Folder>
<Folder Name=".vs" TargetFolderName=".vs" />
<Folder Name="Resources" TargetFolderName="Resources">
<ProjectItem ReplaceParameters="false" TargetFileName="testCommand.png">testCommand.png</ProjectItem>
</Folder>
<Folder Name="Ribbon" TargetFolderName="Ribbon">
<ProjectItem ReplaceParameters="true" TargetFileName="RibbonItems.cs">RibbonItems.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="RibbonManager.cs">RibbonManager.cs</ProjectItem>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="AddinManifest.addin">AddinManifest.addin</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="App.cs">App.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="ExternalCommand.cs">ExternalCommand.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="RibbonCommand.cs">RibbonCommand.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="StringLocalizer.cs">StringLocalizer.cs</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>
Binary file added src/__TemplateIcon.ico
Binary file not shown.

0 comments on commit a4594e7

Please sign in to comment.