Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 04-10-2018, 02:18 PM
kumaichi kumaichi is online now
Registered User
 
Join Date: 08-01-2014
Posts: 5
Expanding a macro in a custom action

I created a global macro:
<?xml version='1.0' encoding='utf-8'?>
<macros version='9'>
<macro name='TF_EXE_PATH'>
<description>Path, including the exe file to your local systems TF.exe</description>
<value>%DEVSTUDIO_NET_DIR%\Common7\IDE\TF.exe</value>
</macro>
</macros>

Inside my custom action (C#), I try to expand the macro like so:
IMacros macros = builder.App.get_Macros( MacroTypeEnum.vbldMacroGlobal );
builder.LogMessage( builder.App.ExpandMacros( Convert.ToString( macros[ "TF_EXE_PATH" ].Value ) ) );

When I run my step, I get the following error:
Exception: System.NotImplementedException: The method or operation is not implemented.
at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Dynamic.ComRuntimeHelpers.CheckIfMissingTyp eInfoIsExpected(Int32 hresult, Boolean throwIfMissingExpectedTypeInfo)
at System.Dynamic.ComRuntimeHelpers.GetITypeInfoFromI Dispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)
at System.Dynamic.IDispatchComObject.EnsureScanDefine dMethods()
at System.Dynamic.IDispatchComObject.System.Dynamic.I DynamicMetaObjectProvider.GetMetaObject(Expression parameter)
at System.Dynamic.DynamicMetaObject.Create(Object value, Expression expression)
at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
at System.Runtime.CompilerServices.CallSiteBinder.Bin dCore[T](CallSite`1 site, Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at CallSite.Target(Closure , CallSite , Application , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at VersionManager.Manager.CheckoutAIFile(String AssemblyInfoPath, IStep step, Builder builder)

I've tried using:
builder.ExpandMacros(...)
builder.App.ExpandMacros(...)
builder.App.ExpamdMacrosAndScripts(...)

All of them say that the method isn't implemented.

Any suggestions I could try?

Thanks,

Craig
Reply With Quote
  #2  
Old 04-10-2018, 07:34 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
I'm not sure -- I added the following line to the NETAction user sample (Samples\User Actions\NETAction):

Code:
builder.LogMessage(builder.App.ExpandMacrosAndScript("%VISBUILDDIR%"));
and it logged

C:\Program Files\VisBuildPro9

when built.

Does it work for you?
Reply With Quote
  #3  
Old 04-10-2018, 08:10 PM
kumaichi kumaichi is online now
Registered User
 
Join Date: 08-01-2014
Posts: 5
If I run your code, it writes out the same string that you posted. I noticed that you're not getting the macro prior to calling the ExpandMacro method so I tried this:

builder.App.ExpandMacros( "%TF_EXE_PATH%" );

And that worked, so I'm not sure what's wrong with my method but it works so hopefully someone can learn from my issue.

Thanks for the quick response.
Reply With Quote
  #4  
Old 04-10-2018, 09:19 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
This also worked:

Code:
IMacros macros = builder.App.get_Macros(MacroTypeEnum.vbldMacroAll);
builder.LogMessage(builder.App.ExpandMacrosAndScript(macros["VISBUILDDIR"].Value.ToString()));
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 11:15 PM.


Copyright © 1999-2023 Kinook Software, Inc.