For the first time in a .NET Core project I've had to use a conditional compiler directive:
#if DEBUG
// Set something here ...
#endif
I wanted to double check that the DEBUG constant is actually defined for the Debug configuration, since I inherited this project from another dev team and I've learned not to take things for granted. The DEBUG constant isn't defined anywhere in the project file but I see tantalizing hints online that perhaps some default compiler constants are now defined implicitly. For example: https://github.com/dotnet/sdk/pull/565
However, I can't find any documentation about this feature. Can anyone explain how standard compiler constants, like DEBUG, are now defined in .NET Core?
The DEBUG should be defined in VS already. You can find it via the project's properties page on the build tab -> Define DEBUG constant.
And other predefined symbols include the DEBUG and TRACE constants. You can override the values set for the project using #define. The DEBUG symbol, for example, is automatically set depending on your build configuration properties ("Debug" or "Release" mode). More detail information, see C# Conditional compilation
You can so refer the following screenshot:
In Debug mode, and unchecked the "Define DEBUG constant" option:
In Release mode, and unchecked the "Define DEBUG constant" option:
In Debug mode, and checked the "Define DEBUG constant" option:
In Release mode, and checked the "Define DEBUG constant" option:
Related
I'm trying to build and deploy ASP.NET web application via TeamCity and WebDeploy.
Before you ask - I found several similar questions, but neither of them worked in my case.
I'm trying to pass TeamCity parameters to MsBuild. I have a build template which defines the parameters as empty, and then build configuration override them.
Tried system properties, but they didn't work for me. What's even worse, TeamCity doesn't log MsBuild parameter values, so I can't take a look at them.
Here's the example of how I pass parameters to MSBuild in my build template:
/property:MsDeployServiceUrl=https://$(deploy_vm_name):8172/MsDeploy.axd /property:DeployIisAppPath=$(deploy_app_name) /property:SkipExtraFilesOnServer=True /property:UserName=$(deploy_username)
/property:Password=$(deploy_password).
According to the documentation, syntax is correct.
Parameters are system.deploy_app_name, system.deploy_username, system.deploy_password, system.deploy_vm_name.
The error message I get - C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4115, 5): Invalid Web Deploy service URL.
I'm using TeamCity version 10.0.2 with MsBuild version 14.
Any suggestions? What did I miss?
So the correct move was to specify system parameters named exactly after MSBuild parameters and then don't mention those parameters in MSBuild step. After I did that, all went fine.
I recognize it's not very flexible solutions since you might have several MSBuild steps, but if anyone knows better one - please share it
I think because you're defining these properties via arguments in a build step, you need to use the typical %teamcity.parameter% syntax where you are using instead the $(msbuild_parameter) syntax.
Or just skip setting them on the command line entirely. You should be able to resolve the system.parameters from TeamCity in the MSBuild script using the $(msbuild_parameter) syntax.
From the documentation you linked:
For MSBuild (Visual Studio 2005/2008 Project Files) use $(). Note that MSBuild does not support names with dots ("."), so you need to replace "." with "_" when using the property inside a build script.
You aren't inside a build script, you're outside the script defining property arguments.
I have a doubt over this question
Question: What is the correct order of precedence to setup runmodes in aem? (From left to right, left beign the highest)?
A. System property, Sling properties file, jar file
B. jar file, sling properties file, system property
C. Sling properties file, jar file, system property
D. jar file, System property, Sling properties file
Answer : B
I had gone through various docs and had done multiple experiments over this.
Acc to Adobe documentation the order is - Sling.properties, System property, jar file
Similarly, this Adobe doc has a contradictory opinion - jar file, sling.properties, system property
Also, Apache Sling Doc says that any property to option D (-D) set in manner, n=v, overwrites same named properties in the sling.properties file. which means system property has higher precedence then sling.properties.
Now, these are all according to docs, what I had experimented is-
I made a path ${dir}/crx-quickstart/conf and created a file sling.properties and wrote sling.run.modes=publish. Then renamed the jar file as cq-author-7502.jar. Then run this jar with the command java -jar cq-author-7502.jar -Dsling.run.modes=prod
This is my observation:
1. When the jar runs, Setting 'sling.run.modes' to 'publish' from sling.properties. this message is shown in the terminal.
2. The instance up in author mode. And
3. When I checked the instance-mode in felix console, it was prod
I am totally confused about the order of precedence. As everything seems contradictory to me.
It would be grateful if anyone can put some light on it..
Thank you
I think it depends on when we are checking the run mode precedence, at the time of installation or later on a running instance and how we are starting our instance. There are 2 kinds of run modes. Installation time run mode, custom run modes.
Installation time run mode - As explained by official run modes documentation and setup instructions, this can be set only one time at the time of installation. This includes author,publish,nosamplecontent,samplecontent
Custom run mode - Own customized run modes e.g. dev, qa, prod etc
I did some tests (AEM 6.1), precedence is working in following way
Initial setup
Start jar (by double clicking) - In this you do not have option to set run mode in sling.properties, start script first time. JAR name takes precedence.
Unpack jar and specify run mode as system properties in start script - JAR name doesn't comes to picture here. In this you do not have option to set run mode in sling.properties. System properties takes precedence.
Running instance
Even if we change run mode in JAR name, it doesn't changes the installation time run mode. For custom run mode, JAR file name is not applicable. Order of precedence is sling.properties -> specifying -r option (command line jar option) -> system properties (start script)
As far as the question (seems to be AEM certification question), the context is not clear with respect to which they are asking. Helpx article is contributed by community, context might be different. Sling documentation link (it seems as per this link the launchpad version in AEM is old, not 2.4.0). Need to ask Adobe to confirm :).
There are two conflicting Adobe articles that say something quite different
Article 1: (Assumed more recent)
Starting CQ with a specific run mode If you have defined
configurations for multiple run modes then you need to define which is
to be used upon startup. There are several methods for specifying
which run mode to use; the order of resolution is:
sling.properties file
-r option
system properties (-D)
Filename detection
From this Reference: Configure Run Modes
- the answer is C
Article 2:
Behavior when run modes are specified more than one way The run mode
specified in the naming of the jar file takes precedence. If run modes
are not specified in the naming of the jar file, the values in the
sling.properties file are used. If run modes are not specified in
either the naming of the jar file or the sling.properties file, the
system property (or JVM argument) is used.
From this Reference: Configure Run Modes
- the answer is B
However based on my experience and based on process of elimination I'd go with answer B.
Once deploying ASP.NET application, is there any difference between
changing debug=false and remove the entire content of debug=true?
From the documentation:
http://msdn.microsoft.com/en-us/library/s10awwz0(v=vs.85).aspx
debug
Optional Boolean attribute. Specifies whether to compile debug
binaries rather than retail binaries. The default is False.
So no difference at all.
in FlashProfessional, there is a concept called "Config constants" which get set in the Publish Settings. They can be used for conditional compilation as explained here http://help.adobe.com/en_US/Flash/10.0_UsingFlash/WS3e7c64e37a1d85e1e229110db38dec34-7fa4a.html#WS7D94A7C3-8F91-421a-936C-F076374C470F
Question: how do you set config constants in the FlexBuilder IDE?
Thanks!
Set it in Additional compiler option in the following way: -define+=CONFIG::isRelease,false
When I try to compile my application in flash develop. it wont compile. even if I put a simple trace in the Main class. Nothing happen. the sdk is in the correct place.
You can try a few different things. But make sure for these tests that you have a trace in your main constructor.
First, go to your project settings (Project > Properties). On the Output tab un-check "no output", and select "Play in popup" in the "Test Movie" drop down menu. Then test your application (F5).
Take not of a few things; What appears in the output panel (if you don't have it open, go to View > Output Panel). Does it show something like this?
/*
Running process: C:\Program Files\FlashDevelop\Tools\fdbuild\fdbuild.exe ...
Using the Flex Compiler Shell.
Building ProjectName
mxmlc -load-config+=obj\ProjectNameConfig.xml -debug=true ...
Starting new compile.
Loading configuration file C:\Flash\flex_sdk_3\frameworks\flex-config.xml
Loading configuration file C:\Flash\Projects\ProjectName\obj\ProjectNameConfig.xml
obj\ProjectName634012614944137992 (228743 bytes)
(fcsh)Build succeeded
Done (0)
[Capturing traces with FDB]
*/
Are you missing any of the above lines in your output panel while testing you application?
If you don't see any of this in your output, or your own trace, then create a new test project, add a trace, and try again.
do you have it linked to the compiler correctly?
There is a chance that upgrading the compiler or FD could have changed the setting.
Also you could try compiling through the Flash IDE. As a test or a solution.