How do I include appsettings.json configuration settings in a nuget package? - json

I am running .net core 1.1, nuget 3.5, and hosting packages on VS team services.
I looked into transformations here: https://learn.microsoft.com/en-us/nuget/create-packages/source-and-config-file-transformations,
But I need a solution for json files, not config files.
I read that you can use an install.ps1 script to include the file, but I also read that install.ps1 is deprecated.
What is the current method for including json configuration files in a nuget package?

Try to use <files> node in the .nuspec file. Example from here:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<!-- ... -->
</metadata>
<files>
<!-- Add a readme -->
<file src="readme.txt" target="" />
<!-- Add files from an arbitrary folder that's not necessarily in the project -->
<file src="..\..\SomeRoot\**\*.*" target="" />
</files>
</package>

Related

How to set NuGet environment variable NUGET_CERT_REVOCATION_MODE` to false on appcenter.ms

I am working on Xamarin.Forms app that is using a private NuGet feed.
For iOS building, I use appcenter.ms that is recommended by Microsoft. I have set up the NuGet restore step via API key by adding Nuget.config next to .sln file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="DevOps" value="https://xxx.pkgs.visualstudio.com/_packaging/xxx/nuget/v3/index.json" />
</packageSources>
<apikeys>
<add key="https://xxx.pkgs.visualstudio.com/_packaging/xxx/nuget/v3/index.json" value="%encrypted_api_key%" />
</apikeys>
</configuration>
However, nuget restore on appcenter.ms takes so long that build times-out after 30 minutes.
I suspect that issue is the Revocation check mode
I would need to set the NUGET_CERT_REVOCATION_MODE to false.
How to set NuGet environment variable NUGET_CERT_REVOCATION_MODE to false on appcenter.ms? or disable it some other way?

Visual Studio Team Services release XML transformation doesn't work

Visual Studio Team Services - Build & Release
In the release definition, under File Transforms & Variable Substitution Options, there are XML transformation, and XML variable substitution.
I checked both checkboxes, but after deployment, nothing in my Web.Dev.config replaces web.config. The transformation doesn't happen at all.
What is the problem?
--------edit: detail---------
build
all the settings here is default.
release
web.dev.config
This transformation works fine if I deploy from visual studio 2015.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=tcp:xxxx.database.windows.net,1433;Database=xxxx;User ID=xxx#xxx;Password=xxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add name="NicoContext" connectionString="metadata=res://*/Nico.csdl|res://*/Nico.ssdl|res://*/Nico.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:xxxx.database.windows.net,1433;initial catalog=xxxx;User Id=xxxx#xxxx;Password=xxxx;App=EntityFramework"" providerName="System.Data.EntityClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
<appSettings>
<add key="Environment" value="Dev" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="AzureStorageContainerName" value="xxx" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="FacebookLoginAppId" value="xxx" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="FacebookLoginAppSecret" value="xxx" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>
</configuration>
--------edit 2: no longer work ---------
I did as the solution suggested on a new project in another Azure account, but this time it didn't work. For build, I choose template "Asp.net (preview)", for release, I choose template "Azure App Service Deployment".
--------edit 3: Release - Package or folder ---------
You have already deployed/published the web app, so the web.config has already been transformed (For web package deployment, the related values in web.config will be updated during web deploy, the values are in parameters.xml).
So, there isn’t other config files (e..g web.dev.config, web.release.config) in published folder and check XML transformation and XML variable substitution is useless.
Based on the build log, the web app build with release configuration, but there isn’t web.release.config, so there isn’t update for web.config.
You can refer to these steps to achieve your requirement:
Publish/deploy the web app with File System way (e.g. /p:WebPublishMethod=FileSystem /p:publishUrl= $(build.artifactstagingdirectory)\)
Add Copy file step copy others config files (web.dev.config, web.prod.config etc) to the published folder (artifact directory)
Add Publish Build Artifacts
For release, uncheck Publish using Web Deploy option and specify $(System.DefaultWorkingDirectory) to Package or folder.

Delphi dcc32 and manifest compilation

How to compile a Delphi project using DCC32.EXE with the default manifest file?
I've compiled some project and the Task Dialog doesn't appear because of missing the manifest file.
When I compile from the IDE everything works fine but when I use the DCC32.EXE the Task Dialog component doesn't work.
I think the problem in the version info file.
Create a file and name it anything.xml
Write the following into the file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="App" version="3.1.0.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
Create a resource file such as proj_manifest.rc and write the following line into it:
1 24 "anything.xml"
Compile the resource file using brcc32.exe
Add the following line to the project source:
{$R 'proj_manifest.res'}
Compile the project using the dcc32.exe and thats all.

Creating library jar with other libraries

I am creating jar via eclipse, but not runnable jar, it is just a library. After importing that i'm creating new project and adding this jar file. But when run application it throws exception about not finding libraries which are inside in my jar. But these libraries are included in created jar. Where is my mistake ? How can I do that ?
You cannot, by default, include dependency JAR files inside your JAR file, you need a plugin, as specified in Classpath including JAR within a JAR (suggested by Artur Malinowski). If, however, you wish to create a JAR which simply works with your other dependencies, you can easily do this via Eclipse by right clicking on the project, going into properties, Java Build Path, Libraries and then you can add JARs, etc. by using the buttons along the right side of the menu (as of Kepler).
I hope this helps.
P.S. You'll have to cart round the dependency JAR files wherever you put the main JAR, however, this is the easiest and most straightforward approach to getting it working in the first place, and then refine later, using build plugins.
I found the solution. I write some ant script for creating jar and it was solved my problem.
<target name="dist" depends="build-jar">
<property name="store.jar.name" value="MYJARNAME"/>
<property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging project into a single JAR at ${store.jar}"/>
<mkdir dir="dist"/>
<delete dir="${store.dir}"/>
<mkdir dir="${store.dir}"/>
<mkdir dir="dist/lib"/>
<copy todir="dist/lib/" overwrite="false" granularity="9223372036854">
<fileset dir="lib/"/>
</copy>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${store.dir}/temp_final.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/temp_final.jar"/>
</target>

Code coverage results are not available in TeamCity

I am using TeamCity 7.1 with MsBuild build step running the following task:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BuildTrunk" DependsOnTargets="Compile;Test" />
<Target Name="Compile">
<MSBuild Projects="Project.sln" Targets="Rebuild" Properties="Configuration=DEBUG" />
</Target>
<Target Name="Test">
<NUnitTeamCity Assemblies="#(TestAssemblies)" NUnitVersion="NUnit-2.5.10" />
</Target>
<ItemGroup>
<TestAssemblies Include="Project.Tests\bin\Debug\Project.Tests.dll" />
</ItemGroup>
</Project>
And I configured PartCover for this step (set path to PartCover 4.0.2 libraries, used proper XSLT files, also copied just in case PartCover.dll and renamed it to PartCover.CorDriver.dll), however once tests are executed code coverage results are not available and "Code Coverage" tab is not displayed in TeamCity. What is wrong with this configuration?