How to publish WCF Service Library and get transformed web.config? - wcf

I have WCF Service Library project and have configured slow cheetah extension for transforming .config files.
When I run publish on the project the build output produce in bin folder appropriate dll file for the service and NameOfService.dll.config file which is transformed correctly.
The publish process also produce .svc and web.config file. The issue is that the web.config file is not transformed.
Is it possible to get also web.config file transformed by this process and how ?

Related

Specifying web.config without overriding existing one?

In an ASP .NET Core application, there is no default web.config file in the project. However, when I run dotnet publish, there is a web.config file present in the output directory.
But what if I want to modify some web.config values, and have those merged into the published web.config?
It seems I just wasn't paying enough attention. If I make a web.config file in my project with new properties, it is merged into the generated web.config on publish.

WebAPI project doesn't seem to post transformed web.config to bin folder?

I've bene doing well with .NET config transforms. I have them in place now on a class library for data usage and a WPF app.
However, when I attempt to set them up with an ASP.NET WebAPI project, something strange seems to happen.
The config file never shows up in my bin directory, and so the web.config always shows as the pre-formed config file.
If I run MSbuild with parameters of "/t:TransformWebConfig /pConfiguration=Test" on the csproj, I see the following:
CollectWebConfigsToTransform: Found The following for Config
tranformation: Areas\HelpPage\Views\Web.config, Web.config,
Views\Web.config, bin\Web.config PreTransformWebConfig: Skip copying
Web.config to obj\Test\TransformWebConfig\original\Web.config, File
obj\Test\TransformWebConfig\original\Web.config is up to date Skip
copying C:\Users\killesj1\Repositories\MRP Trunk\Macro
Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config to
obj\Test\TransformWebConfig\original\bin\Web.config, File
obj\Test\TransformWebConfig\original\bin\Web. config is up to date
TransformWebConfigCore: Skipping target "TransformWebConfigCore"
because all output files are up-to-date with respect to the input
files. TransformWebConfigCore: Skipping target
"TransformWebConfigCore" because all output files are up-to-date with
respect to the input files. PostTransformWebConfig: Transformed
Web.config using Web.Test.config into
obj\Test\TransformWebConfig\transformed\Web.config. Transformed
C:\Users\killesj1\Repositories\MRP Trunk\Macro
Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config using
C:\Users\killesj1\Repositories\MRP Trunk\Macro
Projects\VEUploader\src\app\VEUploader.WebAPI\Web.Test .config into
obj\Test\TransformWebConfig\transformed\bin\Web.config.
It appears that the transformation is tranforming the file, but somehow it's not making its way back into the bin directory, where the old Web.config remains.
Is this normal? How might I get this to behave similarly to other web transforms?
I had a similar problem, deploying Test projects on Appveyor that weren't being transformed, and followed the advice in the link below and now everything works nicely. I had all my projects set up to do xxx.config transforms in the [Target Name="AfterBuild"] and it worked perfectly on my local dev machine, but on pushing the code to Appveyor, the tests would fail because of untransformed files etc. Basically, move everything to the [Target Name="BeforeBuild"] and see if that helps.
MSBuild - how to force "AfterBuild" target when I do deployment?
web.config normally located in the root and is not copied to bin subfolder. To apply transforms you need to have some template web.config and transform it to root web.config.
E.g. see https://stackoverflow.com/a/16239488/52277 and Use Visual Studio web.config transform for debugging

How to specify MSDeploy parameters from MSbuild

I have a web application that I am trying to deploy and have the web.config file parametrised.
I can build the package by running
msbuild myproj.csproj /T:package
now when it produces the package, i get a file in the directory.
Archive.SetParameters.Xml
This file has Parameters in it that if I change they would end up in the deployed package. My Question is, how can i define more parameters so that when I build the project it has my extra parameters in the file.
I belive i could do it using MSDeploy -declareParam But how would I do this from MSBuild? or the .csproj file.
My end goal is to have a parametrised Web.config file for deployment into multiple environments.
Ok so turns out this is fairly easy, after some significant googling eventually found this post
http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html
VS 2010 makes your life easier by allowing you to simply drop the
Parameters file in the root of your web project and if a file with the
name Parameters.xml is found in the root of your project it passes it
to Web Deploy which then parameterizes your web…

WCF, how stop stop log4net file being created on build

I am having a problem with the log4net file in a WCF service i have created.
When i build and run my WCF services it created log4net then errors with the following...
"Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format."
When I delete the fle from the bin folder and refresh the browser the services run fine.
So, how can i stop the log4net being created in the bin foler when i build my project? as i dont need it
Somewhere in your service project, you probably have a reference to a log4net assemly. Or the log4net assembly is referenced in another assemly that is referenced in your service project. Somehow it is chained-in as a dependency for your service to be deployed and is therefore copied into your bin folder.
Find the reference to the log4net assembly, select it and select Properties from its context menu. In the Properties window set Copy Local to false. This will prevent the assembly to be copied into the output bin folder.

Deploying WCF Services

I have a WCF visual studio project, which contains many SVC files.
Can I compile each SVC file into its own dll file?
my target is to be able to deploy each svc file separately without touching other services, but maybe keep them on the same website
what options I have?
No, you cannot compile the svc files.
You can however compile your actual service code into an assembly (if you haven't stuck it into YourFile.svc.cs codebehind file), and then deploy that compiled assembly into the bin directory below the virtual directory where you svc files exist.
If you want to have an assembly for each service, you will need to create a class library project for each service, put the service implementation inside that, compile it, and then deploy that resulting assembly into the bin directory.
The svc files must be deployed as is, and they must be copied into a virtual directory (or a subdirectory thereof) in IIS.