How to override a configuration property? - msbuild-4.0

I am trying to do both Release and Debug builds on .Net v4.0, where I have a MSBuild project file rather than a solution file. I want to use the same build project file, but just override the Configuration property switching between "Debug" and "Release".
When I execute as follows
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" /verbosity:Diagnostic
I get the following error
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):
error : The OutputPath property is not set for project
'buildinv.proj'. Please check to make sure that you have specified a
valid combination of Configuration and Platform for this project.
Configuration='Debug' Platform=''.
I can see that that the error is occurring in _CheckForInvalidConfigurationAndPlatform.
If I pass an OutputPath property it will however work
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" "/property:OutputPath=."
Is this a known bug ? Where I need to override the Configuration property I am going to get forced to override the OutputPath property even though i do not wish to.
Thanks in advance.

In my project files OutputPath property is defined in the property groups specified for every Configuration & Platform. If you don't set correct Platform, OutputPath property is not set and your build will fail.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
Add Platform property into your command line:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;Platform=AnyCPU" /verbosity:Diagnostic

Add one of the following to your project file. The error means OutputPath environment variable is not getting it's value. By removing the "Condition=" from PropertyGroup, OutputPath will always be set for any platform or configuration, by default.
<PropertyGroup>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(DefaultOutputDirectory)</OutputPath>
</PropertyGroup>

If you don't want to modify the project file, you can also just specify the OutputPath for the build in your command:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;OutputPath=C:\MyOutputPath" /verbosity:Diagnostic

Related

Attribute is required but not set (Unable to create snapshot class for interface)

My Liferay 7 server was using SomeModule happily, until I deployed a new version of SomeModule which has an additional required field favoriteColor.
Now whenever I try to load the portlet Liferay says:
java.lang.RuntimeException: Unable to create snapshot class for interface some.SomeModuleConfiguration
at com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil._createConfigurableSnapshot(ConfigurableUtil.java:77)
at com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil.createConfigurable(ConfigurableUtil.java:51)
at some.SomeModule.activate(SomeModule.java:50)
...
aused by: java.lang.IllegalStateException: Attribute is required but not set favoriteColor
at aQute.bnd.annotation.metatype.Configurable$ConfigurableHandler.invoke(Configurable.java:75)
at com.sun.proxy.$Proxy1220.favoriteColor(Unknown Source)
at some.SomeModuleConfigurationSnapshot407.<init>(Unknown Source)
The configuration UI for SomeModule does not show anything about favoriteColor.
How to fix that, for instance by setting favoriteColor to its default value?
An alternative path would be using a OSGi configuration file to set defaults and missing values. You can use those files as you do for those modules that come with liferay; e.g., elasticsearch config. (check your osgi/configs directory)
If you are lucky enough to have the source code of the module, you can solve this problem like this:
Temporarily make the new field optional, but replacing required = true to required = false in SomeModuleConfiguration.java.
Deploy the module.
Load the configuration page, save.
Restore to required = true.
Deploy again.
Alternative answers welcome!

Configuration management in builds without source controlled config transformations

Given a configuration named "Data:ConnectionString" in appsettings.json file (ASP.NET Core application), how do I override this in the build? By overriding it can either be that there is a step which changes the value in appsettings.json before compilation during build, or that I override the parameter when using "dotnet test", or something else.
More info:
I have a ASP.NET Core application with standard configuration in appsettings.json. I do not want any connection string or sensitive data checked in the source control.
I am building my application using Visual Studio Team Service (cloud TFS). There is a step where tests are executed, and I want these tests to run against a remote service for which I do not want to check in the credentials.
There are a number of extensions available on http://marketplace.visualstudio.com that will help you without any complicated ness.
https://marketplace.visualstudio.com/items?itemName=YodLabs.VariableTasks
I like the Variable Tasks Pack that comes with:
Set Variable Set a variable value and optionally apply a transformation to it.
Set Variables with Credential Sets the username/password from an existing service endpoint
Set Variable from JSON Extracts a value from JSON using JSONPath
Set Variable from XML Extracts a value from XML using XPath
Update Build Number Allows you to change a build number
Increment Version Increments a semver version number
Super easy... You can also just search for "json" or "variable" to find other options...
Most popular ways:
Use app secrets
Use scripts section in your project.json. You have 4 events -
precompile, postcompile, prepublish, postpublish
You can set the an environmental variable ASPNETCORE_ENVIRONMENT in the build to something like "Test". Create an appsettings.json file named appsettings.Test.Json. Then when you are setting up your configuration in Startup.cs do something like...
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
When the environmental variable is set to TEST, you new appsettings file will be loaded and can set the connection string to whatever you want.

Bean missing error when deploying SnappyData-0.5 pulse.war

I am trying to deploy the Pulse Web Application to an external Tomcat. I get this error when deploying. How should I fix this?
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'org.springframework.security.authenticationManager' is
defined: Did you forget to add a gobal
element to your configuration (with child
elements)? Alternatively you can use the authentication-manager-ref
attribute on your and elements.
OK. This is fixed. To everyone also experiencing this... you must set the Spring Profile "pulse.authentication.default" or it will not load the AuthenticationManager Bean.
The overall issue is with the RowStore's documentation, which says this is OPTIONAL, when in fact it is required.
http://rowstore.docs.snappydata.io/docs/manage_guide/pulse/quickstart.html#topic_795C97B46B9843528961A094EE520782
It says at Step 4.) that configuring security is Optional when in fact you have to pass a Spring Profile. Also, again in the section "Authenticating Pulse Users", it says this is not a requirement.
To fix the issue I had to pass the Spring Profile "pulse.authentication.default" to activate the Bean in spring-security.xml and deploy pulse.war properly.
A better way for SnappyData pulse.war to do this in the future might be to use "!pulse.authentication.custom", which would always load the default AuthenticationManager bean as long as a custom one was not configured.
Example change for future to make it truly optional:
<beans:beans profile="!pulse.authentication.custom" >
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
Which version of Tomcat are you using?
Here is another thread on the same issue with TC authentication.
Else, can you just try Pulse in the "embedded mode" ?
Which version of SnappyData you are using ?
You need to mention a pulse.properties file in the classpath . For details you can check http://rowstore.docs.snappydata.io/docs/manage_guide/pulse/quickstart.html#topic_795C97B46B9843528961A094EE520782.
Let us know if you any problems further.

con:settings Elements in Workspace and Project Files

I am using the free edition of SoapUI (version 4.6.1) with multiple workspaces. One of my frustrations is that SoapUI does not seem to support workspace-level custom properties.
The *-soapui-workspace.xml files I have reviewed contain an empty con:settings element (i.e. <con:settings/>). Same in the *-soapui-project.xml files I have reviewed.
My intuition & hope is that these elements allow workspace- or project-level additions to or overrides of settings I see in my general soapui-settings.xml file - e.g. additional global properties that I want when a given workspace is loaded.
However, when I create a settings file SomeService Tests-soapui-settings.xml that contains...
<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-settings xmlns:con="http://eviware.com/soapui/config">
<con:setting id="GlobalPropertySettings#properties"><![CDATA[<xml-fragment xmlns:con="http://eviware.com/soapui/config">
<con:property>
<con:name>WorkspaceCustomPropertyTest</con:name>
<con:value>some value</con:value>
</con:property>
</xml-fragment>]]>
</con:setting>
</con:soapui-settings>
...and set the con:settings element in the SomeService Tests-soapui-workspace.xml file like so...
<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-workspace name="SomeService Tests" soapui-version="4.6.1" projectRoot="${workspaceDir}" xmlns:con="http://eviware.com/soapui/config">
<con:description>Workspace to organize all SomeService test projects.</con:description>
<con:settings>SomeService Tests-soapui-settings.xml</con:settings> <!-- Reference the workspace settings file. -->
<con:project name="SomeService Authentication Tests">SomeService Authentication Tests-soapui-project.xml</con:project>
</con:soapui-workspace>
..., nothing happens.
I do not get an error upon loading the workspace, but I also do not get any indication that the con:settings element is doing anything either. For example, SoapUI Preferences > Global Properties does not list a WorkspaceCustomPropertyTest property.
I can keep tinkering of course, but an explanation of the workspace- and project-file con:settings elements would help.
Searching SO, the SmartBear SoapUI forum, and more broadly for an explanation of the workspace- and project-file con:settings elements has yielded nothing so far.
Can anyone explain how to use the workspace- and project-file con:settings elements?
Alternatively, can anyone shed light on how to achieve a similar result (i.e. workspace-level custom properties) with the free edition of SoapUI?
What about that?
Create a ini("myconfig.groovy") file("assuming that this file will be in the same directory of your project file"):
global_property='Global value'
Use this groovy script to grab the property:
// Script imports
import com.eviware.soapui.support.GroovyUtils
import groovy.util.ConfigSlurper
// Grovvy utils handle OS directories path abstraction
def groovyUtils = new GroovyUtils(context)
def config = new ConfigSlurper().parse(new File(groovyUtils.projectPath + '/myconfig.groovy').toURL())
// Just logging the property but you can set the property here
log.info config.global_property
Then you can add the value to the desired object at run time.
It doesn't seem possible to do it at the workspace level. You could do it at one of the testing levels, see: http://www.soapui.org/Functional-Testing/working-with-properties.html
SoapUI does support global properties.
In File> Preferences> Global Properties
Here you can assign Global Properties that spans all projects. Sadly, currently, it will be used for all work spaces. Hope this helps, having a groovy script to manually handle everything just seems a bit over kill to me.

Spring.NET PropertyPlaceholderConfigurer using ${my value}

My Spring.NET configuration is using the following type syntax and is working ok.
<object id="JohnUsingVariableSource"
type="XmlConfig.StringInjection.Person, XmlConfig">
<property name="Name" value="${JohnsFullName}" />
</object>
Values for the ${JohnsFullName} placeholder are configured in the app.config file. My requirements have changed and I know need to get the name from the database at startup. How is it possible to overwrite the value in the app.config file ? Can I do it in code without opening the app.config (as here App.Config change value), does spring.NET have a way of doing this ?
Yes, you can do that without modifying the app.config file. Simply implement a custom IVariableSource:
public interface IVariableSource
{
string ResolveVariable(string name);
}
In the ResolveVariable method you read from the db.
The first variable source configured in your config will be the one used by the spring config, if I recall correctly.