Relationship between solution configuration, publish profile, and web.config transforms - visual-studio

I have the following setup in a Visual Studio 2013 ASP.NET Web API 2 project.
Web.Develop.config web transform to set an app settings key value
Web.Release.config web transform to remove an app settings key
Develop.pubxml to map to the Web.Develop.config transform
Release.pubxml to map to the Web.Release.config transform
Details for each are found below.
<!-- Web.Develop.config (Web Config Transform) -->
<appSettings>
<add key="ReportInputPath"
value="DevelopPath"
xdt:Transform="SetAttributes"
xdt:Locator="Match(key)" />
</appSettings>
<!-- Web.Release.config (Web Config Transform) -->
<appSettings xdt:Transform="Remove" />
<!-- **Develop.pubxml (Publish Profile) -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x64</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>Path</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles
<ExcludeFilesFromDeployment>packages.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
<!-- Release.pubxml (Publish Profile) -->
<!-- Contents are identical to Develop.pubxml.
This is used to target the Web.Release.Config transform. -->
Whenever I publish the application via the Release publish profile my <appSettings/> element is successfully removed. However, <appSettings/> element is removed when the Develop publish profile is run as well.
What I want to understand is:
Why is the <appSettings/> element being removed when I run the Develop publish profile instead of setting the ReportInputPath value?
And what are the relationships between the between solution/project configurations, publish profiles, and web.config transforms?

The answer to why the <appSettings/> element is being removed when the Develop publish profile is run is because two transformations are run in the following order.
Web.Release.config. This is run because the configuration target in the Develop.pubxml file is the Release build configuration.
Web.Develop.config. This is run because the name of the publish profile (Develop) matches the name of the transform file.
What is happening is the the first transformation removes the <appSettings/> element. The second transformation attempts to set the key value in that element, but cannot find it, so it silently fails.
I was able to confirm this by searching through the console output. When the Develop transformation was run there was a warning that the desired element could not be found.
Example (shortened for clarity)
> TransformXml: Applying Transform File: C:\...\MyProject\Web.Develop.config
> C:\...\MyProject\Web.Develop.config(6,4): Warning : No element in the source document matches '/configuration/appSettings'
> TransformXml: Not executing SetAttributes (transform line 9, 10)
The Profile specific web.config transforms and transform preview article by Sayed Ibrahim Hashimi was very helpful in identifying this was the issue.
As far as the relationship between the build configuration, publish profiles, and web.config transform go my current understanding is this.
Publish profiles have (among other things) a configuration target
Publish profiles first run the transformation that maps to the their specified configuration target name if one exists
Publish profiles then run the transformation that maps to their publish profile name if one exists
The key here being that two web.config transformations may be run.

Related

B2C Authentication with WebForms

I have a legacy WebForms application. I need to add Azure B2C authentication to it. My application is using currently Microsoft.Aspnet.Identity. It does not have any startup.cs page. How can I make this migration?
Some minor things allow you to switch your site to use AAD or aadb2c for authentication.
Get the necessary OWIN NuGet packages, Add some startup code to use the OWIN authentication libraries ,Register your application in AADb2c.
Update your web.config with appropriate OAuth values.
Even though OWIN didn’t exist when you wrote your Web Forms app, you can still use it and it will significantly simplify the process.
In the Visual Studio menu, select Tools > NuGet Package Manager > Package Manager Console.
Make sure your web project is selected in the Default project drop down.
Run the below commands:
install-package Microsoft.Owin.Host.SystemWeb
install-package Microsoft.Owin.Security.OpenIdConnect
install-package Microsoft.Owin.Security.Cookies
You may check the references and then follow this B2C-WebForms-DotNet
References:
c# - ASP.NET Web Api - Startup.cs doesn't exist - Stack
Overflow
c# - OWIN Startup Class Missing - Stack Overflow
edit:
My web forms if for visual C# and could find owin start up :
Right click on App_Start > add item > under web , you can find it.
Please check if your project is visual c# .
edit 2:
Please check if below points help :
Maybe you can create new start up class by using owin library in the clas
Imports Microsoft.Owin.Extensions
Imports Microsoft.Owin.Security
Imports Microsoft.Owin.Security.Cookies
Imports Microsoft.Owin.Security.OpenIdConnect
Imports Owin
Imports System
Imports System.Configuration
Check the web.config file and remove this key setting and try
<add key="owin:AutomaticAppStartup" value="false" />
and also try add <add key="owin:AutomaticAppStartup" value="true " /> in web.config file
The following attribute will set the startup class to the StartUp class in the StartupDemo namespace.
[assembly: OwinStartup(typeof(StartupDemo.StartUp))]
Add appSetting element in the Configuration file
<appSettings>
<add key="owin:appStartup" value="StartupDemo.StartUp" />
</appSettings>
Check how owin detects start up owin-startup-class-detection -Microsoft docs
Other references:
owin-startup-class-not-detected
owin-with-vb-net-legacy-code-asp-net-web-forms
where-to-implement-startup-code-in-vb-net

NetBeans 12.4 - Spring Boot Maven project, debug all test

In a Spring Boot Maven project I have tests with JUnit 5.
Within a test class (annotated with #SpringBootTest) I can select
Test File
Debug Test File
Run Focused Test Method
Debug Focused Test Method
On the project itself (Files window) I can select
Test
which runs all tests.
Is there a way to debug all tests?
So to speak I would expect a selection on the project like Debug Test besides Test.
The reason is, that some errors appear only when I run all tests. But when I run or debug just the erroneous test method or even the whole test class, the errors don't appear.
Sorry I haven't found a more GUI-friendly way yet (and verified only on Netbeans 12.3), but:
a) If you already have a nbactions.xml:
Add the following to the <actions/> element:
<action>
<actionName>CUSTOM-Debug-all-tests</actionName> <!-- should be unique for this project -->
<displayName>Debug All Tests</displayName> <!-- will be displayed in context menu -->
<packagings>
<packaging>*</packaging> <!-- according to your needs, taken from pre-configured action -->
</packagings>
<goals> <!-- according to your needs, taken from pre-configured action -->
<goal>process-test-classes</goal>
<goal>surefire:test</goal>
</goals>
<properties> <!-- according to your needs, taken from pre-configured action -->
<forkMode>once</forkMode>
<maven.surefire.debug>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
</maven.surefire.debug>
<jpda.listen>true</jpda.listen>
</properties>
</action>
(Of course you can modify & adjust it to your needs, but this works for a quickstart (maven) project. Also interesting: "Debug integration test" action!)
Then you can execute it from "Project context menu>Run Maven>Debug All Tests"!
b) If You don't have an nbactions.xml (in your project) yet:
Just modify one of the pre-configured "Actions" (preferably "Debug (Integration) Test") from the "Actions" menu of "Project Properties", this (hitting "OK") will generate the according file at your project root. Then you can make it (maven-) executable as described above (a).(There must/should also be a way to run these Actions without modifying nbactions.xml at least by implementing a custom plugin....but haven't found the action/menu/tab yet:))
There is no need to modify the XML file directly, just
choose the Actions category in Project Properties
choose Configuration (<default config>, or dev (Profile), or...)
click Add Custom button
enter Action Name
fill the fields Execute Goals, Set Properties, etc.
If <default config> is choosen from Configuration, NetBeans will create a file nbactions.xml, otherwise if for example dev (Profile) is choosen a file nbactions-dev.xml is created, and so on.
The custom action is available in the context menue under Run Maven opened on pom.xml

Structure test scripts with liquibase to execute in order with normal scripts

we are using liquibase for migrating database in spring boot application. In resources we have main changelog file which includes other changelogs (1 per version).
We usually differentiate environments by liquibase's context attribute but new we need differentiate data which are only for integration tests, and don't want place it next to normal versioned scripts. Is possible place these integration tests scripts in test's scope of project and execute them in order with normal scripts?
For instance:
main changelog:
<include file="version-1.xml"/>
<include file="version-2.xml"/>
and version 1 sample:
<changeSet id="1ver_1" author="xxx">
<!-- creation of table foo_table -->
</changeSet>
<changeSet id="1ver_2" author="xxx">
<!-- adding column to table foo_table -->
</changeSet>
version 2 sample:
<changeSet id="2ver_1" author="xxx">
<!-- renaming table foo_table to bar_table -->
</changeSet>
I need that if scripts for integration tests will written after script 1ver_1 and will contains inserts, it will be ok if next will be executed 1ver_2 and 2ver_1.
So when db for instegration tests started, scripts will be executed in right order:
1ver_1
test_data for 1ver_1
1ver_2
2ver_1
what is best practice to do that?
I think you should change the way you keep your changesets. Have a look at Liquibase Best Practices.
So your master changelog should look like:
<include file="version-1.1.xml"/>
<include file="version-1.2.xml"/>
<include file="version-2.1xml"/>
If you do this, you can have dedicated master changelog file for integration test. Your integration test's changelog-master.xml will look like this:
<include file="version-1.1.xml"/>
<include file="test_data_version-1.1.xml"/>
<include file="version-1.2.xml"/>
<include file="version-2.1xml"/>
After that you just override property in integration tests:
liquibase.change-log=classpath:integration-liquibase-changeLog.xml
Also you should place integration-liquibase-changeLog.xml and all 'test_data_xx.xml' into integration test module resource or test resource (it depends on project structure). The main idea it should not be provided to production artifacts.

Alfresco Custom Content Type not showing

I have been trying to follow this tutorial about Alfresco custom content types
http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#localizing-strings-for-custom-content-models.
However, when I get to the 'Test your changes' step and I go to manage rules, I can't manage to get the custom types created (sc_doc and sc_whitepaper) in the dropdown list.
My share-config-custom.xml:
<!-- Share configuration related to this particular Share module extension, such as:
- Doclib action config
- Form config
- Aspect and Type config
Note. Any configuration related to the whole Share.war webapp
(i.e. not specific to this share extension) should be
placed in the environment specific config:
alfresco/tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml file
-->
<alfresco-config>
<!-- Document Library config section -->
<config evaluator="string-compare" condition="DocumentLibrary">
<aspects>
<!-- Aspects that a user can see -->
<visible>
<aspect name="sc:webable" />
<aspect name="sc:productRelated" />
</visible>
<!-- Aspects that a user can add. Same as "visible" if left empty -->
<addable>
</addable>
<!-- Aspects that a user can remove. Same as "visible" if left empty -->
<removeable>
</removeable>
</aspects>
</config>
<config evaluator="node-type" condition="DocumentLibrary">
<types>
<type name="cm:content">
<subtype name="sc:doc" />
<subtype name="sc:whitepaper" />
</type>
<type name="sc:doc">
<subtype name="sc:whitepaper" />
</type>
</types>
</config>
</alfresco-config>
PS: Do I have to re-run 'mvn install' after every change I make in the .xml using Eclipse?
Any help will be much appreciated!
I know i am posting this answer bit late
and my solution is bit poor, But it works for me :)
I hope it will also work for you.
Strange thing is i am following same tutorial and at the time of 'Test your changes' stage not able to see my custom types on the server.
so to make it working in my share project i have changed place of
share-config-custom.xml
from src/main/resources/META-INF to src/main/amp/config/alfresco/web-extension
and restart alfresco and now able to view my custom types in type list on server.
plz post your answer if you have make done this by any other way :)
thank you.
I am not sure which kind of project you have created from maven artifacts.
Repository AMP archetype
All-In-One (AIO) archetype
Share AMP archetype
Here you can see list of all maven commands.
If you are not using local maven repository then you can go for "mvn package" to generate new AMP files and then deploy them manually on alfresco server.

Where to place the I18N message properties for a custom (cm:storeSelector) aspect in Alfresco Share?

I enabled the cm:storeSelector aspect in Alfresco Share 4.1.x, as described in the "Alfresco Administrator Guide" (pg. 281).
I tried adding these messages
aspect.cm_storeSelector=Store Selector
cm_storeSelector=Store Selector
both under
/shared/classes/alfresco/messages/slingshot.properties
and
/shared/classes/alfresco/extension/webclient.properties
This is my share-config-custom.xml:
<alfresco-config>
<!-- cm:content type (existing nodes) -->
<config evaluator="node-type" condition="cm:content">
<forms>
<!-- Default form configuration for the cm:content type -->
<form>
<field-visibility>
<show id="cm:storeName" />
</field-visibility>
</form>
</forms>
</config>
<!-- Document Library config section -->
<config evaluator="string-compare" condition="DocumentLibrary">
<!--
Used by the "Manage Aspects" action
For custom aspects, remember to also add the relevant i18n string(s)
cm_myaspect=My Aspect
-->
<aspects>
<!-- Aspects that a user can see -->
<visible>
<aspect name="cm:storeSelector">
<title>Store Selector</title>
</aspect>
</visible>
</aspects>
</config>
</alfresco-config>
Problem is: the aspect name does not show in the Alfresco Share UI ("Manage Aspects" Dialog) - instead it only shows the string aspect.cm_storeSelector on the right hand side:
while it shows fine on Alfresco Explorer:
I am wondering where to place the I18N strings correctly for Alfresco Share.
Just putting the messages into (a custom) alfresco repository message bundle should be enough to make the translations appear "everywhere" - in share as well.
The key is to follow the name mapping convention.
Have a look at alfresco/WEB-INF/classes/alfresco/messages/content-model.properties
where it reads:
cm_contentmodel.aspect.cm_titled.title=Titled
cm_contentmodel.aspect.cm_titled.description=Titled
which corresponds to alfresco/WEB-INF/classes/alfresco/model/contentModel.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="cm:contentmodel"
...
<aspect name="cm:titled">
A similar mapping convention applies to properties, types and associations as well. Examples of those can be found across those three files as well.

Resources