WinJS are there #DEBUG or #RELEASE directives?
Asked Answered
S

2

0

I would like to exclude some code when using release vs debug. Basically I have an internal admin section for testing that I don't to ever make it into the app store by accident :)

Ideally, I would just be able to do something like this:

#IF DEBUG
    <div id="appBar" data-win-control="WinJS.UI.AppBar">
        <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdmin', label:'Admin', section:'global' }">
        </button>
    </div>
#ENDIF
Sociality answered 4/12, 2012 at 12:52 Comment(0)
I
2

See here. There is a nuget package here to enable it without adding the code to your project directly. After you have it then you just do:

<script src="/js/debugSymbols.js"></script> 

if (Debug.isDebugBuild) {

Here is the full code that you don't need if you use the nuget package:

(function () {     
   "use strict";
   if (Debug.hasOwnProperty("isDebugBuild")) {
     return;
   }
   var thisPackage = Windows.ApplicationModel.Package.current,
            installedPath = thisPackage.installedLocation.path;
   if (typeof installedPath === "string") {

       if (installedPath.match(/\\debug\\appx$/i)) {

           Object.defineProperty(Debug, "isDebugBuild", {
              get: function () {
                 return true;
              }
           });
       }
   }
})(); 
Inocenciainoculable answered 4/12, 2012 at 15:12 Comment(1)
Be aware that this will not work if you create a package of your debug configuration and install it on another computer (for testing purposes).Canescent
I
1

I have been researching about it, I found the following (which is based on configuration manager in your VS solution)

Moreover I am considering to use MSBuild tasks (or MSBuild Inline Tasks) to replace text in specific file based on the current configuration (e.g. DEBUG, RELEASE). This should happen in the beforeBuild event. This may also work for setting specific values based on deployment.

Cheers, Herb

Insulate answered 7/8, 2014 at 3:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.