Can I use an environment variable in Obfuscar config file? - obfuscar

The obfuscar config file needs to specify "InPath" and "OutPath". Is it possible to use an environment variable? If yes, how?The reason is that this config file is in SVN and then should be used by people having their projects locally in different locations where the environment variable points to.
e.g.
<Var name="InPath" value="%MYDEVPATH%\Project\bin\Release" />
instead of
<Var name="InPath" value="c:\foo\foo\foo\Project\bin\Release" />
regards,Tobi
edited: changed $(MYDEVPATH) to %MYDEVPATH%

It is impossible yet. Obfuscar does not attempt to evaluate environment variables.
I can create a work item to track this request and let you know once it is implemented.
Updated:
Fixed in https://github.com/lextm/obfuscar/commit/97eaa12ac75b2246bba64dd74752caa635ef8f7a
Should be part of vNext.

Related

How to use NLog to write to different file according to parameter

I want to be able to write to logs to a different log file according to one of my log parameters.
Lets say, bankId. Each day and bank will write to their own file like
2019-11-11-bank11.log
2019-11-12-bank11.log
and so on.
How can i achieve that programmatic with some kind of a pattern for the log file.
I don't want to create a new version of my app every time I have a new bankid.
You could set the context in one of the context classes and render it with a layout renderer.
e.g. use ${mdlc} and MappedDiagnosticsLogicalContext:
Config:
<target name="file" xsi:type="File"
fileName="${basedir}/${mdlc:bankid}.log" .. />
Code:
using (NLog.MappedDiagnosticsLogicalContext.SetScoped("bankid", "bank11"))
{
logger.Info("myLogEvent");
}
See also all context layout renderers
Sounds like you have an application-wide setting. For that you should either use:
NLog Config Variables - ${var:bankid}
Global Diagnostic Context - ${gdc:bankid}
I prefer to use the GDC has it has a minimum number of surprises, when modifying at runtime.
You can do this in NLog.config:
<target name="file" xsi:type="File"
fileName="${basedir}/${shortdate}-bank${gdc:bankid:whenEmpty=0}.log" .. />
Then at application startup then you can do this:
NLog.GlobalDiagnosticsContext.Set("bankid","11");
See also: https://github.com/nlog/nlog/wiki/Gdc-Layout-Renderer
You can also extract a setting from config-file:
app.config - https://github.com/NLog/NLog/wiki/AppSetting-Layout-Renderer
appsettings.json - https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer

persist environment variable value which changed from ant sshexec task

I have created an environment variable named "COUNTER" in "etc/environment" and assigned a value 0 to it. I want to increment and persist its value by using ant script's SSHEXEC task. I wrote the following code to increment its value:
<target name="incrementCounter">
<sshexec
host="${remote.host.ip}"
username="${remote.user.id}"
password="${remote.user.ssh.password}"
command="((++COUNTER))"
trust="true"
useSystemIn="true"
/>
</target>
After command is executed successfully I logged in into linux machine through Secure Shell Client and printed its value, it showed me "0". Is there any way I can achieve this?
Environment variable changes are local to the process which makes them, so this could not possibly work.
You can hack up an ever-increasing counter just by maintaining appropriate file and sourcing it., much like /etc/environment is sourced.
However, the real question is what you are really trying to achieve.

IIS web.config, any other % symbols apart from %s?

Regarding the scriptProcessor in the handlers section of IIS's web.config, are there any % symbols apart from %s (which seems to represent the requested filename)? For example, is %a a recognised macro/symbol? If there are others besides %s, where are they described?
Your question is a bit unclear, so I had to make a number of assumptions in order to answer it. Please let me know if I got anything wrong.
From the documentation:
Script Processor
Optional string attribute.
Specifies the physical path of the ISAPI extension .dll file or Common Gateway Interface (CGI) .exe file that processes the request.
The scriptProcessor attribute is required only for script map handler mappings. When you map a handler to an ISAPI extension, you must specify ISAPIModule for the modules attribute. When you map a handler to a CGI file, you must specify CGIModule for the modules attribute.
From the documentation, we don't see any mention of format strings at all. If there were format strings, what would you replace them with? There's no clear answer based on the XML. Perhaps you're mistaking an environment variable for a format string. Or your particular configuration setup has some post processing that's ran on it before it's pushed live.
If we are actually talking about environment variables, then you can view them by issuing Win+Break to bring up system settings, go to advanced, then open up environment variables. You may also define your own. To use any environment variable you can use %variablename% as you would in a standard .bat file.
EDIT: Upon greater research, I've found the following. %s will give you the script name, then %s again will give you the parameters foo=bar. This feature isn't advertised (that I can find) in any official IIS documentation. I strongly suspect that it's considered a deprecated feature. And they're pushing hard to make ISAPI the norm.
Because of how it's structured (ie like a standard format string) I suspect that trying other common format strings (%d %c %f) might yield you something interesting, but probably not. It looks like this was a very specific solution to a very specific problem.
It's not strictly related to your question but I post these 2 links as they are in some way connected and could be useful.
I've found how to use "#" and "$" to transform Web.Config, but I've found nothing on "%" that's not strictly related to environment variables.
First link: "#"
This first link explains the use of xdt:Transform and xdt:Locator attributes that you can use in Web.config transform files:
http://msdn.microsoft.com/en-us/library/dd465326.aspx
This example is an interesting use of Web.Config transformation using Conditions with "#":
<configuration xmlns:xdt="...">
<connectionStrings>
<add name="AWLT" connectionString="newstring"
providerName="newprovider"
xdt:Transform="Replace"
xdt:Locator="Condition(#name='oldname'
or #providerName='oldprovider')" />
</connectionStrings>
</configuration>
Second link: "$"
This second link shows how to use "$" to transform Web.Config avoiding the boring procedure to manually comment/uncomment Web.Config parts when deploying or testing in different servers:
http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/
An extract of the link, showing how to use MSBuild to transform Web.Config files starting from a Web Application project file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\</OutputPath>
</PropertyGroup>

CCNet Make Version Configurable

I am automating build with CCNEt. The last step of the build is to create a file. Its name will be in the formatAS_V_1.0.0.1_DD_MMM_YYY. 1.0.0.1 is the version number. This version number will be used in multiple multiple projects. So I want this to be a configurable parameter. How can I do that?
What you want is to define a parameter in your CCNET configuration. I wrote about CCNET parameters a while ago.
Essentially, you can define your parameter using
<cb:define KEY=”VALUE” />
and then use the parameter using $(Key)
Example:
<cb:define Version="1.0.0.1" />
and then specify you label as AS_V_$(Version)_DD_MMM_YYY

CruiseControl.NET and Clearcase configuration

I'm having problems simply configuring the server for CruiseControl.NET. I am using the source block that is given by ThoughtWorks to set it up, but I cannot seem to get it to be error-free. I am pretty new to all this and some sort of direction would be fantastic.
Does anyone use this combination?
Do you have a ccnet.config file I can look at?
This is what does not work for me:
<cruisecontrol>
<project name="test">
<sourcecontrol type="clearCase">
<exec>batch file</exec>
<viewPath>path_name</viewPath>
<branch>main</branch>
<autoGetSource>false</autoGetSource>
<useLabel>true</useLabel>
<useBaseline>false</useBaseline>
<projectVobName>vob_name</projectVobName>
<viewName>projecy_name</viewName>
<executable>cleartool.exe</executable>
<timeout>50000</timeout>
</sourcecontrol>
</project>
</cruisecontrol>
Thank you.
I have no direct experience with this kind of setup, but if you are using the <projectVobName> tag, that means:
you are declaring a pvob (project vob used only in UCM to store project, stream, activities and components, all UCM data)
your view (with the root directory referenced in <viewPath>) must be an UCM view.
All the other path elements (like 'executable') should reference an absolute path (and not just "cleartool.exe")

Resources