Coder Social home page Coder Social logo

dansiegel / mobile.buildtools Goto Github PK

View Code? Open in Web Editor NEW
226.0 13.0 30.0 94.33 MB

The Mobile.BuildTools makes it easier to develop code bases in a clean, consistent, secure, and configurable way. Determine at Build which environment your app needs to run on, and what Client Secrets it should have. Plus many more amazing features!

Home Page: http://mobilebuildtools.com

License: MIT License

C# 99.14% CSS 0.10% PowerShell 0.35% TypeScript 0.12% Shell 0.01% HTML 0.13% SCSS 0.12% Sass 0.02%
xamarin msbuild-task build-tools devops mfractor buildtools devops-tools hacktoberfest

mobile.buildtools's Introduction

Mobile.BuildTools

Build Tools

There is a lot of talk these days about DevOps. One of the problems with DevOps is that it can be really challenging. Far too many companies suffer from reliance on poor practices that their Development teams know need to be fixed. Today we have a variety of Build Systems that are at our disposal and we no longer need to rely on such poor practices. Mobile.BuildTools can help turn your run of the mill project into a streamlined DevOps masterpiece. Best of all because the Mobile.BuildTools simply provide new targets for MSBuild it works absolutely EVERYWHERE that MSBuild itself is installed!

IMPORTANT Version 1.x is no longer under development. This is considered a legacy version. Docs for v1.x are located in the Wiki. For those wishing to use the more powerful API's described in the mobilebuildtools.com docs site please use the v2.0 previews.

Background

As part of my frustration at how challenging it was to go from File -> New Solution to a base project that was ready to put into a DevOps pipeline, I set out to create the Prism QuickStart Templates. Part of the templates included many of the features you see in the Mobile.BuildTools. As time went on I realized the need to decouple the tools from the template so as new features were added, or bugs fixed it could be more easily added.

Support

If this project helped you reduce time to develop and made your app better, please be sure to star the project. Also please consider becoming a GitHub sponsor. I spend hundreds if not over 1000 hours a year working on Open Source and your financial contributions help me spend time working on new features and fixing bugs that affect your apps.

GitHub Sponsors

Samples

  • App Config Demo - Sample Xamarin app using the new app.config. This sample uses Xamarin.Forms with Prism to show how you can use this with Dependency Injection and keep your apps testable with the IConfigurationManager rather than using all statics. NOTE: This project does not take advantage of build time transformations.
  • BuildToolsSample - Sample Xamarin app using various build time generated helpers from the Mobile.BuildTools.

Mobile.BuildTools

For more information on the various Build Tasks, and Properties please see the WIKI.

Package NuGet Sponsor Connect
Mobile.BuildTools BuildToolsNuGetShield BuildToolsSponsorConnectShield
Mobile.BuildTools.Configuration BuildToolsConfigNuGetShield BuildToolsConfigSponsorConnectShield
Status
Build Build Status
Integration Tests (Mac) Build Status
Integration Tests (Windows) Build Status
Tests Tests

Want to consume the CI packages? Be sure to sign up as a GitHub sponsor and get the pacakges from Sponsor Connect.

mobile.buildtools's People

Contributors

axemasta avatar bijington avatar chowarth avatar dansiegel avatar dependabot-preview[bot] avatar dependabot[bot] avatar jtorvald avatar kzu avatar matthewrdev avatar reallinfo avatar seanalford avatar tiagodenoronha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mobile.buildtools's Issues

Automatic Type Definitions Get Cleared During Build

Description

When Running a build with more than one project, If a project has a secrets.json, the updated Secrets Task will generate the schema for the new Secrets config automatically and attempt to add this to the project config. It manages to update and save the project secrets element, however later in the build pipeline this gets reverted to its initial state.

Reproduction Steps

Steps to reproduce the behavior:

  1. Have a solution with more than one project
  2. Add a secrets.json with no config

Expected Behavior

As each project builds it will add the secrets configuration to the buildtools.json

Actual Behavior

Project Secrets element gets nulled out

Environment

  • OS: Windows 10 & OSX
  • IDE: all
  • BuildTools Version: 2.0-ci
  • IDE Version: n/a
  • Build Target Framework: n/a

Reproduction App

E2E tests

Build Host Environment Dump

SUMMARY

Sometimes things just aren't working in a CI environment and it would be really helpful to build an empty dummy project that could show us exactly what the BuildTools is able to see.

DETAILS

The goal will be to be able to add a simple project like:

<Project InitialTargets="CIEnvironmentDump">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Mobile.BuildTools" Version="*" />
  </ItemGroup>
</Project>

The Build Target will have to be explicitly called as this will leak data that really should not be in the build logs under normal circumstances. Before using such a process any sensitive Environment variables should be updated with dummy values. The goal will be to see all of the Variables that the BuildTools will have access to. This will better assist in setting up CI pipelines by ensuring that there isn't some weird issue with the Build Host that is preventing the BuildTools from working correctly.

The Build Target will also set the Enable MobileBuildToolsDebug so that if you are generating Secrets or a updating a Manifest, the contents will be printed to the Logs as well.

Android Version Code must be an int

The timestamp is producing a value that is a long when the Version code requires an int. This will need to be fixed for long term support.

Debuging on IOS on a device

there are a couple issues with target file when trying to run a debug build on a physical device,

you get this error

[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form

Decouple Manifest Copy and Token Replacement

Description

Currently missing App Manifests are copied from a staging directory to the project with all tokens replaced in one step. While this is more performant, it also locks developers into using this method to benefit from the token replacements.

Proposal

Create a new task that handles token replacement of Manifests that are already in the correct location and remove the token replacement from the current Manifest Copy task.

Changes

No breaking changes as the same steps will occur, just broken up into two tasks to allow different scenarios.

Xamarin iOS build cannot find namespace on CircleCI

Description

Xamarin iOS build using Mobile.BuildTools and MSBuild works perfectly locally but fails on CircleCI because of <PROJECT>.cs(13,32): error CS0234: The type or namespace name 'Helpers' does not exist in the namespace '<PROJECTNAME>' (are you missing an assembly reference?) [/Users/distiller/project/PROJECT-NAME/PROJECT-NAME.csproj] Mobile.BuildTools is added as a package and reference on both the Android and iOS sections of my project as well as the base section and Android works great locally and on CircleCI. I've tried Xbuild, verified identical versions of MSBuild, added _SdkShortFrameworkIdentifier: xamarin.ios to my CircleCI environment, and tried different versions of Xcode (10.1.0 and 10.2.0).

Reproduction Steps

Steps to reproduce the behavior:

nuget restore

msbuild iOS/<PROJECT-NAME>.iOS.csproj

Expected Behavior

MSBuild using Mobile.BuildTools to locate Helpers/Secrets.cs on CircleCI macOS environment.

Actual Behavior

MSBuild using Mobile.BuildTools cannot locate Helpers/Secrets.cs on CircleCI macOS environment despite doing so on local macOS environment.

Environment

  • OS: macOS 10.14.4/CircleCI Version 2.0 macos machine executor
  • IDE: Xcode 10.2.1/Visual Studio for Mac Community 8.0.4
  • BuildTools Version: MSBuild 16.0.42.19328
  • Build Target Framework: Xamarin.iOS

No Secrets.cs file is generated

Hi there,

I've read the blog and the wiki to try and understand how I use this package but I think I must be missing something.
I've added the NuGet package to my project, Xamarin Forms .Net Standard, dropped a file called secrets.json in the root of the project and run a build.
Now I'm expecting a Secrets.cs file to be generated but nothing. Am I missing an obvious step here or is something not working?

Thanks
Adam

Build fails on AppCenter

Hello again

I have my Secrets.cs generating happily from the secrets.json when I build locally, however when I build on AppCenter the build fails with:

error CS0103: The name 'Secrets' does not exist in the current context

This makes sense because that class isn't going to get generated without secrets.json being in the source but obviously my secrets.json file shouldn't be checked in. I've had a look at the demo app but I can't see what I should do to resolve this error.

Thanks for any help :)

Add Version Bump Task

A very common requirement is to bump the version number as part of the CI build. The Task should:

  • Support VSTS & AppCenter
  • Provide a default format while allowing overrides
  • Default behavior should transform 1.0 -> 1.0.$(BuildNumber)

Build Host Task Fails

The Build Host Task is failing silently. It appears that the Logger is never being set so the failure is pretty silent.

SCSS Processing Optimizations

Description

Currently SCSS Files are processed into CSS on every single build with a lot of noise. This results in processing that doesn't actually need to occur. This occurs in part due to all items with a None Include being evaluated as part of the process. This should be filtered to only files with the .scss extension. Ideally this should be further reduced to only processed on file update such as when a partial or a specific scss file is updated.

Generated CSS should also be moved to the Intermediate Output Directory to reduce the in project file noise.

VSTS Capitalizes all build variables

Description

When adding environment variables in VSTS a variable added to the Build Definition like HelloWorld will be added to the environment as HELLOWORLD making it harder to discover and impossible to ensure that the correct variable name is used when generating the json file and thus the Secrets Class.

Reproduction Steps

Create a build definition for a UWP project in App Center or any build definition in VSTS with a Windows Client (I believe this may also be occurring on the Mac agent with VSTS). Add variables to the build definition. All variables added to the environment are capitalized.

Expected Behavior

If a variable is expected to be in the json as HelloWorld, we need a way of compensating for environments that prevent us from trusting the variable name is in the format we expect.

Actual Behavior

Environment variables are either undiscovered or discovered incorrectly resulting in capitalization errors that cause the build to fail.

Environment

  • OS: Windows
  • IDE: n/a
  • BuildTools Version: all
  • IDE Version: n/a
  • CI Environment: App Center - Windows / VSTS

Building with dotnet cli throws "Could not load file or assembly" error

Description

Trying to build via cli dotnet build throws error.

***/.nuget/packages/mobile.buildtools/1.4.0.638/build/Mobile.BuildTools.targets(56,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)

Reproduction Steps

Clone example repo
cd DotNetBuildErrorExample && dotnet build

Expected Behavior

I'm building on Appcenter in order to run UnitTests and dotnet test is failing during the build process.

Actual Behavior

The build process dotnet build is throwing this error.
I believe it's due to the version mismatch (Newtonsoft.json version 10.0.3 with the NetCore BuildTools)

Environment

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.302/

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.1.302 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Reproduction App

https://github.com/shwanton/DotNetBuildErrorExample

Mono 5.8 broke Automatic Versioning

Something in Mono 5.8 seems to have broken the Automatic Versioning. With Automatic Versioning turned on Xamarin Android's java tool fails, and Xamarin iOS has the IBTool fail.

Add Json Configuration

Description

Currently configuration settings must be applied to via MSBuild properties either through a props file or in the csproj PropertyGroup. This makes the configuration harder to set, and more prone to errors. By adding a json configuration file with a schema provided this will be easier to for developers to config and will be more discoverable.

Proposal

The build tools will attempt to discover a configuration file named buildtools.config.json with a schema file provided on schemastore.org. The resulting configuration file could look something like this:

{
  "ArtifactCopy": {
    "DisableBuildToolsArtifactCopy": false
  },
  "AutomaticVersioning": {
    "AutomaticVersionBehavior": "PreferBuildNumber",
    "AutomaticVersionEnvironment": "All",
    "AutomaticVersionOffset": 0
  }
}

IPACopyToStagingDirectory Target error on VS4Mac but not VSTS

Hi,

When trying to build in VS for Mac I'm getting the following error:

...../packages/Mobile.BuildTools.1.4.0.638/build/Mobile.BuildTools.targets(25,25): Error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. Invalid path (MSB4184)

This is generated from the IPACopyToStagingDirectory Target in Mobile.BuildTools.targets as $(IpaPackagePath) is ''. How do I disable this step from happening please?

I already have a copy step in the VSTS builds so this part of the tools aren't necessary right now and copying twice will increase build time.

Please note that the iOS project builds correctly via a VSTS agent, this issue only occurs locally on VS for Mac.

Cheers,

Ali.

protect secrets in build output

Currently the build secrets are exposed in the build logs. This can be very useful for debugging but probably isn't the best idea in production. A new parameter should be defined to conceal secrets by default, while allowing developers to override this behavior for debugging purposes.

VSTS secrets not getting generated

Description

I've added the buildtools nuget package to a Xamarin Forms 3 project (.net standard, iOS, Android, UWP heads)

I added a secret.json file with the endpoint of our develop api, in the VSTS CI build for our iOS project I added a Process variable with the name Secret_ApiEndpoint.
image

on build the Secret_ApiEndpoint gets ignore, but the P12password that is used for the apple provisioning task gets turned into an entry

from the output:
` Generating secrets.json for Secret_
{
"P12PASSWORD": "*****"
}
Secrets:

OutputPath: /Users/vsts/agent/2.138.6/work/1/s///Helpers
// ------------------------------------------------------------------------------
//
// This code was generated by Mobile.BuildTools. For more information or to
// file an issue please see https://github.com/dansiegel/Mobile.BuildTools
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
//
// NOTE: This file should be excluded from source control.
//
// ------------------------------------------------------------------------------

namespace Helpers
{
internal static class Secrets
{
internal const string P12PASSWORD = "*****";
}
}

Writing Secrets Class to: 'obj/Release/netstandard2.0/Secrets.cs'`

Reproduction Steps

Steps to reproduce the behavior:

  1. Go to VSTS
  2. Setup a CI pipeline Xamarin iOS
  3. Add a variable that should end up as a secret
  4. See error

Expected Behavior

The variable to get picked up by the secret generating task

Actual Behavior

Variable gets ignored

Environment

  • VSTS, Hosted macOS Preview
  • BuildTools Version: 1.4.0.638
  • IDE Version: [1.x.x]
  • Build Target Framework: Xamarin Forms 3.1 with .net standard 2.0

logo design

Hello! I want to contribute on your project with making logo design. What do you think about it?

Replace PowerShell script with Compiled Tasks

Not all environments may have PowerShell installed. As a result we will need to remove this requirement and replace the PowerShell script with a compiled task that can execute cross platform. This will provide a better user experience for platforms such as Mobile Center.

Error System.IO.FileNotFoundException

Severity Code Description Project File Line Suppression State
Error System.IO.FileNotFoundException: Could not load file or assembly 'System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Mobile.BuildTools.Generators.SecretsClassGenerator.Execute()
at Mobile.BuildTools.Tools.SecretsJsonTask.Execute()

=== Pre-bind state information ===
LOG: DisplayName = System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/
LOG: Initial PrivatePath = NULL
Calling assembly : Mobile.BuildTools, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null.

LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
Dinkkiia.CloudUtilities C:\Users\Chrisgate.nuget\packages\mobile.buildtools\1.0.2\build\Mobile.BuildTools.targets 52

App Manifests - Base on .json-File when building locally

Description

Tokenized Manifests are great on a CI environment, but switching values while having to build locally is not as smooth. It would be great if we could have a similar approach as with App Secrets.

Proposal

Look for a manifest.json in the platform projects and and replace the placeholder values in the templated manifests with the values from the file. This would play out very well with #20.

Parameterize Secrets Class Name

While the default Secrets class name should remain intact, some developers may wish to customize this to their own needs. This will need to become a parameter that can be overridden.

Two netstandard projects with secret.json

Description

I have two netstandard projects like MyProject.Core and MyProject. In both is installed Mobile.BuildTools and both have the secrects.json file added with his corresponding variables.

In local it's working fine but when I'm send a build in azure pipeline, only the first project get the variables working.

Reproduction Steps

Steps to reproduce the behavior:

  1. Create Xamarin.Forms project and add an additional net standard 2.0 project that depends on the PCL.
  2. Install Moblie.BuildTools in both PCL projects and add secrets.json file.
  3. In both csproj add SAFE_ in a PropertyGroup
  4. Create an Azure Pipeline with this variables and queue this build.
  5. You will see that first PCL works but the second don't catch the variables.

Expected Behavior

Create in both PCL the Secrets.cs with the values of this variables.

Actual Behavior

Create in both PCL the Secrets.cs without the values of this variables.

Environment

  • OS: [OSX]
  • IDE: [VSMac]
  • BuildTools Version: [1.4.0.638]
  • IDE Version: [7.7.3 (build 43)]
  • Build Target Framework: [netstandard2.0]

Reproduction App

No included an repo.

Secrets file not getting made

I added the json file in the root and built my project but I have no intellisense for the secrets object, is this only for XF or can it be used for xamarin native and I'm just missing a critical step?

App Manifests - Multi-Platform CI Build Configurations

Description

When working with a single build definition in which more than one platform target is being built, there may be times in which a token name may be the same, but the value needs to be different. There are also times in which they may be the same.

Proposal

The App Secrets can currently be generated on a Platform Target by specifying the Platform Name in addition to the typical prefix. By searching for key with the default Manifest_ and {Platform Name}Manifest_ we can specify environment variables that can be reused across platform targets in addition to ones that may have different values but the same token name.

Changes

This will not cause breaking changes, but will enable more advanced scenarios with less project specific configuration.

app.config Encryption

SUMMARY

To support best practices with the new app.config support in v2.0, the Mobile.BuildTools should make it extremely easy to encrypt and decrypt any app.config in your projects. By encrypting the config this make it safer to use in the event that the config is either checked into source control or an app package (i.e. IPA/APK) is exploded as an unencrypted config would potential expose any secrets.

Generate Release Notes

Description

There are many times where you may want to generate Release Notes based on Git History. This could be based on the number of days or a number of commits. As with all of the BuildTools the goal is to make it easier to facilitate DevOps without having to rely on a large number of build tasks or reproducing scripts from one project to the next.

Behavior

This will be an entirely opt-in feature. The guidance will be to add Settings as solution wide props, while explicitly opting in at a project level.

<!-- Directory.build.props in the Solution root -->
<Project>
  <PropertyGroup>
    <!-- Defaults to 7 if not specified by the user -->
    <ReleaseNotesLookbackDays>3</ReleaseNotesLookbackDays>
    <!-- Defaults to 5 if not specified by the user -->
    <ReleaseNotesLookbackCommits>10</ReleaseNotesLookbackCommits>
  </PropertyGroup>
</Project>

Then in the project:

<!-- Could be AwesomeApp.iOS or AwesomeApp.Android -->
<Project>
  <PropertyGroup>
    <EnableReleaseNotes>true</EnableReleaseNotes>
  </PropertyGroup>
</Project>

The generated Release Notes will have a default location under the Solution Directory in the Artifacts folder as this where generated App bundles are already copied.

Special Considerations

VSTS has the concept of a BuildArtifactStagingDirectory. We will automatically detect if this variable is set, and if so we will save the ReleaseNotes there for VSTS. Further investigation will need to be done to determine how we can make this useful in App Center.

Can't locate the Solution Directory

Thank you for this great tool. I'm trying to set up build on AppCenter, but it's always failing with error

Build started 7/1/2018 3:59:17 PM.
Project "/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/Test_MobileTools.Android/Test_MobileTools.Android.csproj" on node 1 (PackageForAndroid target(s)).
_CreatePropertiesCache:
  Creating directory "obj/Release/".
TemplateManifest:
  Checking for Platform Template Configurations to Copy
  SdkShortFrameworkIdentifier: ''
  Prefix: 'Manifest_'
  Token: ''
  ManifestTemplatePath: '/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/build/AndroidTemplateManifest.xml'
  ManifestOutputPath: '/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/Test_MobileTools.Android/Properties/AndroidManifest.xml'
/Users/vsts/.nuget/packages/mobile.buildtools/1.3.0.599/build/Mobile.BuildTools.targets(35,5): warning : Could not locate template manifest at '/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/build/AndroidTemplateManifest.xml' [/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/Test_MobileTools.Android/Test_MobileTools.Android.csproj]
_SetLatestTargetFrameworkVersion:
  Found Java SDK version 1.8.0.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(602,2): error : AndroidManifest file does not exist [/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/Test_MobileTools.Android/Test_MobileTools.Android.csproj]
Done Building Project "/Users/vsts/agent/2.134.2/work/1/s/Test_MobileTools/Test_MobileTools.Android/Test_MobileTools.Android.csproj" (PackageForAndroid target(s)) -- FAILED.

Build FAILED.

The path ManifestTemplatePath looks good but anyway AppCenter can't find this file. I tried to build your project, and it's can generate manifest.
I just created empty forms project, add nuget package and copy build folder and directory.props from your repository. Here's my test repo

Project Secrets Configuration

SUMMARY

There are a number of cases where we might want to specify specific behavior when either generating the secrets.json or parsing it to the Secrets.cs. We also want to drop the requirement to have variables prefixed with pure magic in CI. The solution will be to provide a configuration file which will define which variables should be generated in the secrets.json in CI, and how they should be handled when generating the output Secrets.cs.

DETAILS

The Mobile.BuildTools should look for a file secrets.config in the Project Root. If the file exists it will use and prefer it. The configuration will look like:

Ok some progress on this... in 2.0 we will continue to exhibit the same behavior as we currently do... however we will also support a new config file option (and prefer it if it exists).

{
  "AzureADClientId" : {
    "type": "Guid"
  },
  "OAuthScopes": {
    "type": "String",
    "isArray": true,
    "delimiter": ";"
  }
}

In this configuration we will specify various properties. Any property that exists here we will look for in the environment in a case insensitive way. We will for legacy reasons continue to look for Secret_{Name} and we will look for Name. Any supported property type can be supported as a string. We will use a semi-colon by default if a delimiter is not specified.

Supported Property Types

  • String
  • DateTime
  • DateTimeOffset
  • Int
  • Long
  • Double
  • Decimal
  • Guid
  • Bool
  • Uri
  • TimeSpan

PLATFORMS

All

Add support to secrets.json of arrays of primitives

SUMMARY

As a consumer of Mobile.BuildTools I want to have possibility to add to secrets.json array of primitives.

DETAILS

Example of secrets.json:

{

    "Scopes": [
         "Scope1Defenition",
         "Scope@Defenition"
   ]
}

Example of Consumption:

string[] scopes = Secrets.Scopes;

PLATFORMS

  • Android
  • iOS
  • UWP

Add .NET CLI Tool

Description

In an effort to better support scenarios around transitioning between environments such as Dev, QA, Staging, & Production, or White Labeling scenarios a .NET CLI Tool should be introduced to handle swapping app Resources & Assets such as the app.config or icons as well as manifests such as the AndroidManifest.xml, Info.plist.

General Support

  • Provide a local path or url link to a zip resource for bundle Assets
  • Provide a local path or url link to a zip resource for bundle Resources
  • Provide a Flag whether to transform or simply replace the bundle's app.config
  • Provide a local path for the new app.config
  • Provide a file name for the bundle's app.config in the event you do not follow the standard naming convention
  • Provide new App Name (if not specified this will not change)
  • Provide new Bundle Id (com.company.appname) to allow side by side install
  • Provide Build Number
  • Provide Version Number

Android Specific

  • Certain folders such as drawable-xhdpi are renamed during build with resources going into drawable-xhdpi-v4. When recursing the directory structure within the Resources we will need to check for a folder named {name}-v4 when the folder name from the zip does not match with the provided bundle.
  • Provide path to keystore with Alias, & Password
  • This will need to support both APK's and AAB's

iOS Specific

  • Set APS Environment (Development/Production) - alter the Entitlements.plist
  • Flag to swap groups in Entitlements (i.e. if base name is com.contoso.awesome, and that exists in Entitlements that name should be replaced with updated Bundle Id)
  • Local Path to Signing Certificate
  • p12 Password
  • Local Path to Provisioning Profile
  • Support for getting latest Provisioning Profile directly from Apple - ROADMAP This probably will not be included in the first release

Specific secrets.json file for a configuration

SUMMARY

Have different secrets.json files for different configurations. Now we have to manually change the secrets.json properties if we change the configuration. Perhaps there is an easier way to set a specific secrets.json file for a specific configuration.

DETAILS

Would like to specify different secrets.json file for different environments (e.g. development, staging, production, etc). Solutions could be:

  • use prefixes for the secrets.json files and specify in the csproj file which json file to use for a configuration.
  • Specify an array of different secrets configs in one secrets.json file, and select on the array key.
  • v2.0 will have a configuration.json (#22). Maybe can add a secrets property there.

PLATFORMS

  • Android
  • iOS
  • UWP

Xamarin Forms 3.0 Breaks SCSS Processing

Description

SCSS Processing is currently compatible only with the last preview of Xamarin Forms 3.0. There was a change to the CSS tasks in the official RTM / SR1 that breaks the Mobile.BuildTools. This should be fixed with #23

BuildHostSecretsTask throws `error : Specified cast is not valid.`

This has been reported several times. Unfortunately it the error isn't giving much in the way of information about the what was being cast.

Target "BuildHostSecrets" in file "/Users/dansiegel/.nuget/packages/mobile.buildtools/1.0.5/build/Mobile.BuildTools.targets":
  Using "BuildHostSecretsTask" task from assembly "/Users/dansiegel/.nuget/packages/mobile.buildtools/1.0.5/build/Mobile.BuildTools.dll".
  Task "BuildHostSecretsTask"
    Output Path: /Users/dansiegel/Projects/Demo1/Demo1/secrets.json
    /Users/dansiegel/.nuget/packages/mobile.buildtools/1.0.5/build/Mobile.BuildTools.targets(41,5): error : Specified cast is not valid.
  Done executing task "BuildHostSecretsTask" -- FAILED.

Question: debug this project while using on a project

Is there a way to debug this project while using on a project?

I see we can set "MobileBuildToolsDebug" to "true" on projectfile and verify log, apart from this any other solution exists, if so could you please suggest?

App Secrets - Multi-Platform CI Build Configurations

Description

When configuring a build that builds more than one platform target, you may wish to share a value across multiple projects. While I cannot think of a good reason to do this across shared and platform code, the scenario may exist. A more reasonable scenario however is when adding secrets to the Platform Targets directly you may wish to share a value that can be reused across those targets.

Proposal

Two new Prefixes should be supported:

  • SharedSecret_
  • PlatformSecret_

When adding an environment variable with the prefix SharedSecret_ it will add the variable to every project built that includes the Mobile.BuildTools. When adding PlatformSecret_ the variable will be reused across all Platform targets, but will not be added to any PCL/netstandard projects.

Changes

No breaking changes.

Support Sass/Scss for Xamarin Forms

Description

CSS is now supported in Xamarin.Forms. While CSS is useful, it is also limiting and can make it harder to style. It's a common practice for instance to define a color palette and then reuse those colors based on the key in existing Xamarin Forms styles. Sass is already a standard for Web Development where these same problems exist. Sass provides an ability to define variables that can be reused throughout your stylesheet which can be colors, fonts, image resources, etc.

Sass/Scss files will need to have a build action of 'None', and will generate Css files in the Intermediate Output Folder (obj) to keep the project code clean. Generated Css will be minimized and have comments stripped to reduce the embedded file size.

Update Build Pipeline

Description

The Release Pipeline needs to be updated to enable the automatic distribution to MyGet and Release/Preview pushing to NuGet along with automatic Releases on GitHub.

TemplateManifest add resolving tokens from secrets file

I have project where I am using google auth.
I use secrets.json for path them to my project:

{
    "ClientId" : "[Id from Google console]"
}

on iOS there one restriction that I need add it to Info.plist:

        <key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLTypes</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.googleusercontent.apps.$$ClientId$$</string>
			</array>
		</dict>
	</array>

Actual Result:
TemplateManifest target use only Environment variables for resolving tokens

Expected:
TemplateManifest target will use secrets.json values for resolving tokens as if secrets.json not exist it will be created by BuildHostSecrets on build server

Set Apple Push Environment

SUMMARY

Apple requires that you have set the Push Environment in the Entitlements.plist. For 99% of builds the default development value is fine for the aps-environment. For that <1% where we are releasing a Production build we need an easy way of updating this during the build.

DETAILS

The goal will to make this as easy to use as a build variable. Rather than relying on tokenization like other tasks, we will simply introduce a Flag variable APSProductionEnvironment. It shouldn't matter what the value of the variable is, only that it exists. If it does we will update the aps-environment to production.

PLATFORMS

  • Android
  • iOS
  • UWP

Not working when on Windows PC Visual studio

I added the Mobile BuildTool and my app refused to build with below errors:

Error The expression "[System.IO.Path]::GetDirectoryName('')" iOS
and
AppCenter error on android

Build i want to use it for is SCSS.

by the way when i uninstall it the solution build with no error.

Thanks

Platform Image Processing

SUMMARY

There are WAY TOO MANY Images in Xamarin projects... we need a simple way that we include the highest resolution version of the image once our git repo and have the resources brought in dynamically at build.

DETAILS

A new property will need to be created. The property will contain a semi-colon separated list of paths that the Task will need to search for image inputs. We will only be handling png's.

Naming Conventions

By default we will output the file name exactly as it is in the base resource folder. This does mean that if you start with an illegal name for the platform you will get build issues. When figuring out what to do with an image we will look for a json file with the same name (i.e. foo.png, foo.json)

Configuration

There will be cases where we need a little extra logic around how to handle images. This could be generic or platform specific. Note that if a Platform value exists it will always override the generic value except in the case of the ignore in which it should either be generally ignored like in the case of a watermark file or ignored at a platform specific level.

{
  "name": "logo",
  "scale": 0.8,
  "ignore": false,
  "watermarkFile": "dev.png",
  "apple": {
    "ignore": "false",
    "name": "AppIcon",
    "scale": 1.0
  },
  "android": {
    "ignore": "false",
    "name": "icon",
    "scale": 1.0,
    "resourceType": "mipmap"
  }
}
Understanding the configuration

**Given the following basic configuration

// Images/Debug/contoso_logo.json
{
  "name": "logo",
  "scale": 0.8,
  "watermarkFile": "dev.png"
}
  • The output image would be would be saved as logo.png not contoso_logo.png
  • The largest output image will be 80% of the input file's size
  • It will not be ignored (note this value should only be set, and set to true if it is a watermark file)
  • It will use the file dev.png in any of the search directories to watermark this image

** Given the configuration in the previous section

  • Given that there is an Android Configuration for this image
    • It will not be ignored (note it should only be specified if true)
    • The largest output will be a 1:1 copy in terms of size to the input file
    • It will be watermarked with the dev.png image
    • It will be saved as a mipmap resource instead of a drawable resource
    • It will be saved as icon.png
  • Given that there is an Apple Configuration for this image
    • It will not be ignored (note it should only be specified if true)
    • The largest output will be a 1:1 copy in terms of size to the input file
    • It will be watermarked with the dev.png image
    • Assuming we have an icon set named AppIcon it will scan the contents json and output the files accordingly.

PLATFORMS

  • Android
  • iOS
  • UWP

Add Copy Artifacts Task

To help assist developers locate build artifacts such as the Android APK or iOS IPA and dSYM, a copy task should be added to automatically copy these files to a local Artifacts directory, and the BUILD_ARTIFACTSTAGINGDIRECTORY on VSTS. This will make it easier for developers to locate and publish either to the App Store, or services such as AppCenter.

Use Default Namespace and not Assembly Name to generate Secrets class

image

We carefully didn't put 'Android' in our namespace, to avoid namespace conflicts. But since the Secret class is generated with the assembly name, the project doesn't compile anymore:

image

namespace XXXX.XXXX.Android.Helpers
{
    internal static class Secrets
    {
        internal const bool IsQAMock = false;
    }
}

The item metadata %(Filename) is being referenced without an item name

Hi, first of all thanks for this tool.

I have this error in "AppCenter.DemoApp", do you know how can i fix it?

..\.nuget\packages\mobile.buildtools\1.2.1.558\build\Mobile.BuildTools.targets(133,5): 
error MSB4095: The item metadata %(Filename) is being referenced without an item name.  Specify the item name by using %(itemname.Filename).

thks

New logo for Mobile.BuildTools

Hello, I designed a logo for MobileBuildTools. I used the mobile icon and ''build tools'' icon. I hope you like it. Also, If you there your a logo idea, i want to hear it.

mbt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.