dansiegel / Mobile.BuildTools

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!
http://mobilebuildtools.com
MIT License
228 stars 29 forks source link

Question: AppSettings and Build on Deploy #296

Closed carbon-paulc closed 1 year ago

carbon-paulc commented 2 years ago

Hi, I have a question regarding AppSettings. I've started using vs2022 (previosult 2019) and am running into problems with the AppSettings generated file and a product called LiveSharp. The error is related to LiveSharp and Cecil, but it seems to be triggered by the AppSettings behaviour.

I've noticed if I Build it generates my Helpers/AppSettings.g.cs file fine. If I then deploy to Android (not tested ios) it then runs the generate again (and outputs the auto generated code to the debug output). This generation seems to kick off something in LiveSharp which then errors - additionally it also triggers the Fody process to run (not sure if that helps). When running in vs2019 - it would seem that the AppSettings is generated on Build but not on deploy.

If I remove the AppSetting from buildtools.json the Build and then Deploy run successfully.

My quesiton is twofold:

  1. is it possible to stop the generate for AppSettings when deploying?
  2. is there a reason this would happen in vs2022 but not 2019?

this is the output from vs2022 when deploying:

LibSass native binary exists at: C:\Users\pcharlton\.nuget\packages\mobile.buildtools\2.0.245\build\libsass.dll
Skipping target "ProcessScss" because it has no outputs.
No resources are out of date with respect to their source files. Skipping resource generation.
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by Mobile.BuildTools. For more information  please visit
//      https://mobilebuildtools.com 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.
//
//      When I wrote this, only God and I understood what I was doing
//      Now, God only knows.
//
//      NOTE: This file should be excluded from source control.
//  </autogenerated>
// ------------------------------------------------------------------------------

using System;
using GeneratedCodeAttribute = System.CodeDom.Compiler.GeneratedCodeAttribute;
... {omitted} ...

Writing Secrets Class to: 'obj\Debug
etstandard2.1\Helpers\AppSettings.g.cs'
Skipping target "XamlG" because all output files are up-to-date with respect to the input files.
Skipping target "ProcessScss" because it has no outputs.
Skipping target "CssG" because it has no outputs.
Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
Skipping target "ProcessScss" because it has no outputs.
Skipping target "CssG" because it has no outputs.

Thanks in advance, Paul.

dansiegel commented 2 years ago

I don't use LiveSharp so I really couldn't tell you what's going on there... that said my guess is that the next version of Mobile.BuildTools will solve things for you as that's when I'm planning on making the conversion to Roslyn Source Generators... but I do not have a time frame as I don't currently have the bandwidth to get any updates on this for the next few months.

carbon-paulc commented 2 years ago

No worries - grateful it's here in the first place.

I think the livesharp error is an unintended consequence of the appsettings regenerating on deploy as well as build.

Do you if there's a way to stop the generation on deploy?