DSpace version 4.x Adding Facet, which messages.xml file should I edit? - facet

After editing Discovery.xml located in C:\dspace-4.2-release\dspace\config\spring\api to add facet, which messages.xml should be edited to add a key,
<message key="xmlui.ArtifactBrowser.SimpleSearch.filter.type">Type</message
because I realized there are 10 messages.xml files in C:\dspace-4.2-release folder. Does anyone know which messages.xml should I add the key? This is for XMLUI Interface.

Given the following facet
<bean id="searchFilterCourse"
class="org.dspace.discovery.configuration.HierarchicalSidebarFacetConfiguration">
<property name="indexFieldName" value="course"/>
Here is the pattern that I follow for providing message text for the facet.
<message key="xmlui.ArtifactBrowser.AdvancedSearch.type_course">Course</message>
<message key="xmlui.Discovery.AbstractSearch.type_course">Course</message>
<message key="xmlui.ArtifactBrowser.SimpleSearch.filter.course">Course</message>

This is the file you need to edit:
[dspace-source]/dspace-xmlui/src/main/webapp/i18n/messages.xml
This is where you should store & manage it in your src tree:
[dspace-source]/dspace/modules/xmlui/src/main/webapp/i18n/
After editing, rebuild with mvn and redeploy.
source:
https://wiki.duraspace.org/display/DSDOC4x/Localization+L10n#LocalizationL10n-XMLUIspecificlocalization

Related

Why aren't ".targets" files imported from Directory.Buid.props not visible in Solution Explorer "Imports" folder?

Solved
The targets WAS there, just buried under Sdk.props->Microsoft.Common.props, which makes sense as that's where it would have been loaded from. My bad.
The Problem
There is a nice feature that displays imported ".props" and ".targets" files in Solution Explorer. These do not seem to display files imported from Directory.Build.props files.
This might be a feature or a bug in Visual Studio or maybe I'm doing something wrong. It is not critical since it is correctly using the Targets2.target file, but it would be helpful to see all my targets files used.
Does anyone understand why this is happening and if there is a change I can make?
This has also been asked in Microsoft Feedback https://developercommunity.visualstudio.com/t/targets-from-directorybuildprops-missing-in-soluti/1605185
Setup C# Project
(or clone https://github.com/MafuJosh/ReproduceVS2022BugDec2021)
in Visual Studio 2022 Pro: Create New Project Class Library - C# - .NET 6
edit the .csproj file, add:
<ImportGroup>
<Import Project="Targets1.targets" />
</ImportGroup>
create Targets1.targets text file in the project folder:
<Project>
<Target Name="Test1" AfterTargets="Build">
<Message Importance="High" Text="from Targets1" />
</Target>
</Project>
create Targets2.targets text file in the project folder:
<Project>
<Target Name="Test2" AfterTargets="Build">
<Message Importance="High" Text="from Targets2" />
</Target>
</Project>
create Directory.Build.props text file in the project folder:
<Project>
<Import Project="Targets2.targets" />
</Project>
Build C# Project
build the project
in Solution Explorer, Show All Files
under now visible Imports folder, we see Targets1.target but not Targets2.target
they both work but only one shows up under the Imports folder
The targets WAS there, just buried under Sdk.props->Microsoft.Common.props, which makes sense as that's where it would have been loaded from. My bad.

Apply transforms to config files on publish

We currently publish our web app vis MSDeploy, to create a .ZIP file (file deployment).
I have some .config files that I want to apply transforms to when we publish. So I've created an appSettings.test.config and an appSettings.live.config.
To facilitate this, I have added this to the csproj of our web app, which applies the transforms:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="ApplyConfigTransforms" BeforeTargets="TransformWebConfigCore">
<TransformXml Source="appSettings.config" Transform="appSettings.$(Configuration).config" Destination="appSettings.config" />
<TransformXml Source="connectionStrings.config" Transform="connectionStrings.$(Configuration).config" Destination="connectionStrings.config" />
</Target>
This hooks in to the TransformWebConfigCore target and does the work. BUT, it applies the transforms to the appSettings file in my web folder (as expected from the destination). What I want to do is apply the transform to the file in the output pacakge.
How can I do this? I don't know how to get a handle on the temporary folder that is created when you publish..
Don't you just hate it when you find the answer yourself about 10 mins after posting.
I hacked the destination, which fixed the issue. Would be nice if I had this in a property, but I couldn't find one to use, so I did:
<Target Name="ApplyConfigTransforms" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
<TransformXml Source="appSettings.config" Transform="appSettings.$(Configuration).config" Destination="obj\Test\Package\PackageTmp\appSettings.config" />
<TransformXml Source="connectionStrings.config" Transform="connectionStrings.$(Configuration).config" Destination="obj\Test\Package\PackageTmp\connectionStrings.config" />
</Target>
Note, I also changed the target, to make sure it happens just after all my files have been copied

Passing dynamic references to Sandcastle Help File Builder

I've been using Sandcastle Help File Builder for a while to generate documentation - I'm now trying to get it to be part of our build process. Our build is controlled using NAnt, and each time it's built the output gets sent to a different location (based on changeset numbers, so we can have concurrent builds without clashes) - ie the dlls are not in a fixed path relative to the source code.
I've added a target into the NAnt script to call SHFB, which invokes the msbuild task, pointing at the solution that contains the SHFB project:
<target name="GenerateDocumentation">
<msbuild
project="${SourceURL}\Documentation\API Documentation\APIs.sln"
verbosity="Detailed">
<property name="OutputPath" value="${OutputPath}Documentation" />
<property name="ReferencePath" value="${OutputPath}wwwroot\\bin\\" />
</msbuild>
</target>
I've specified the ReferencePath property, as on this page, it seems to indicate that this would allow SHFB to find the assemblies and use them, rather than relying on the information in the original project file:
If the ReferencePath property is defined, it will be passed to and used by GenerateRefInfo.proj when generating reflection information. This allows you to specify an alternate path in which to find reference assemblies that will override hint paths in the project file.
However when the build reaches this point, it fails with the following error:
SHFB: Error BE0040: Project assembly does not exist: D:\Build\Debug\wwwroot\bin\MyAssembly.dll
Which is the default output path specified in the original project.
What is the correct mechanism for passing the location of the assemblies into SHFB?
Turns out that using OutDir instead of ReferencePath is the way to go:
<target name="GenerateDocumentation">
<msbuild
project="${SourceURL}\Documentation\API Documentation\APIs.sln"
verbosity="Detailed">
<property name="OutputPath" value="${OutputPath}Documentation" />
<property name="OutDir" value="${OutputPath}wwwroot\bin\\" />
</msbuild>
</target>
Also note that the path specified in OutDir must end in a double slash, otherwise MSBuild attempts to concatenate it with the project path

svc, xml are not being deployed

I'm having problem with publishing WCF service from CI (Cruise Control)..
Let's say I have a WCF project called "WCF-A". I put the following lines in csproj of "WCF-A"
<Target Name="BeforeBuild">
<Message Text="##############Before build##################" Importance="high" />
<RemoveDir Directories="publish" ContinueOnError="true" />
</Target>
<Target Name="AfterBuild">
<Message Text="##############After build##################$(OutputFolder)" Importance="high" />
<MSBuild Projects="$(ProjectName).csproj" Targets="ResolveReferences;_CopyWebApplication" Properties="WebProjectOutputDir=publish\;OutDir=publish\bin\" />
</Target>
I'm using the following to build my service from commandline. (Note that we are using CI but in order to make my question simple, I will use commandline. )
E:\..\Code\>msbuild MyServices.sln /t:Clean;Rebuild
It works perfectly and all assemblies, cross-domain xml, svc files are published under "publish" folder.
The problem come out when I add another services (let's called it "WCF-B") in the solution file. [Edit] I added the same "BeforeBuild" and "AfterBuild" in WCF-B as well. [/Edit] I project-referenced WCF-A from "WCF-B"... but when I build the solution with the same command that I used, the publishing for "WCF-B" is working fine. But the cross-domain file and svc file of "WCF-A" are not being deployed anymore. Only assembly of "WCF-A" are being published under "publish\bin" folder.
Do you guys have any idea why it's happening like that? Thanks in advance.
Edit
I think having "project-reference" creates this problem.. But I need to project-reference instead of calling the service from proxy class. Since both services will be hosted on the same server, I prefer dll-reference over service-calls.
It looks as if the files of WCF-A are being deleted by the BeforeBuild target of WCF-B (assuming that the publish directory resolves to the same directory) and that the assembly WCF-A cannot be deleted because it is referenced by WCF-B and in use.
You might try to increase the log verbosity using /v:d or even /v:diag for further information.
E:\..\Code\>msbuild MyServices.sln /t:Clean;Rebuild /v:d

How to read property value from external file?

I have AssemblyInfo.cs file automatically generated during build. Here's part of .csproj file:
<PropertyGroup>
<Major>2</Major>
<Minor>3</Minor>
<Build>0</Build>
<Revision>0</Revision>
</PropertyGroup>
<Target Name="BeforeBuild">
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="C:\Program Files\VisualSVN Server\bin">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnVersion>
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\Properties\VersionInfo.cs"
AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"/>
</Target>
But I don't know how to specify Major and Minor properties outside .csproj file so I don't have to unload project every time I want to change version. I need either to load them from special text file inside project or to somehow set them in project properties dialog. Any suggestions?
Used ReadLinesFromFile to make version in separate file:
<ReadLinesFromFile File="Properties\Version.txt">
<Output TaskParameter="Lines" ItemName="Ver" />
</ReadLinesFromFile>
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="C:\Program Files (x86)\VisualSVN Server\bin">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnVersion>
<Message Text="Version: #(Ver).$(Revision)" />
<AssemblyInfo
CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\Properties\VersionInfo.cs"
AssemblyVersion="#(Ver).$(Revision)"
AssemblyFileVersion="#(Ver).$(Revision)"/>
It is possible to do this using the ability of PropertyFunctions to call certain .NET functions directly. Essentially, you can call File.ReadAllText() when setting a property value.
<PropertyGroup>
<Version>$([System.IO.File]::ReadAllText("Version.txt"))</Version>
</PropertyGroup>
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="C:\Program Files (x86)\VisualSVN Server\bin">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnVersion>
<Message Text="Version: $(Version).$(Revision)" />
<AssemblyInfo
CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\Properties\VersionInfo.cs"
AssemblyVersion="$(Version).$(Revision)"
AssemblyFileVersion="$(Version).$(Revision)"/>
The Version.txt file would just contain the first three version numbers, i.e. "1.2.3" or whatever.
I'm not sure exactly when this was added to MSBuild, but it was probably after this question was asked and answered.
Use property pages, so you could set these properties on the project property sheets dialogs.
You will need to create a properties file and edit your project file (only once) to add an import directive to your properties file. Here is an example.
You can use your external tools
<Exec Command="newversion incMinor AssemblyInfo.cs > newversion.log" />
If it's locking of the csproj files by VS that's your concern, my answer to this question - How to turn off caching of build definitions in Visual studio might help you.
You could move the content of your BeforeBuild task (including the version propertygroup) into a separate proj file and invoke it with an MSBuild task (using a random filename generated by the example in the linked answer above). This would allow you to manually edit your version number properties without having to unload/load your csproj file.