Deploy different WCF .svc files based on configuration - c#

I have a Service1.svc file that is a normal WCF service. If I deploy the WCF project it will happily copy the Service1.svc file along with the binaries and the other files. So far, so good. What I want is, based on the selected build configuration, or some other trick, to publish different contents for the Service1.svc file.
Let's say I have a Service1.Conf1.svc file and a Service1.Conf2.svc file and two configurations (like Debug or Release) that are named Conf1 and Conf2. When I click publish and have the Conf1 configuration selected, I want the publish folder to have a virtually created Service1.svc file whose contents are from Service1.Conf1.svc. When I click publish and have the Conf2 configuration selected, I want the publish folder to have a virtually created Service1.svc file whose contents are from Service1.Conf2.svc.
I would like to have this for the publish action, not the build action (which could be achievable by a post-build or pre-build event). The main purpose is to adjust the contents of the Service1.svc file according to the publish environment.
Any ideas?

We took a different approach and generate all required config/svc files for all possible installs (using TT file generation) and let the installer copy the correct configs/svc files (based on user selection during install).
The names of the files are constructed by inserting the target platform name into the standard name e.g web.local.config, web.dev.config, web.test.config etc
This way you can give one installer to anyone from any department. They just choose the platform.

Related

How to publish a file only once? ASP.NET vNext

I have a config file which contains version of some client. I need publish this file only once, and it should be same after every publish of web app. How can I do it?
I use Visual Studio Online for continuous deployment and after every push web app in the qa server is updated.
You can use Web Deploy to publish your web app.
By default, Web Deploy determines which files need to be copied to the
server by comparing the dates that the local files were last changed
against the dates that the server files were last changed. If you use
a source control system that changes file dates when you check out
files, it appears that they have all changed, and Web Deploy copies
them all to the server when you publish.
An alternative for this scenario is to configure Web Deploy to use
file checksums to determine which files have changed. Use checksums
only if file dates are unreliable indicators of what has changed,
because comparing checksums takes more CPU processing time than
comparing dates.
Or:
You can limit the files that are deployed by selecting the Only files
needed to run this application or All files in this project options on
the Package/Publish Web tab. If you select the All files in this
project option, you can right-click a file in Solution Explorer and
select Exclude From Project to keep it from being deployed. For more
information about what files are excluded when you use the Only files
needed to run this application or All files in this project options,
see Why don't all of the files in my project folder get deployed?.
If these options are not flexible enough for you, another option is to
edit the .pubxml or the .wpp.targets file and add an
ExcludeFilesFromDeployment element or an ExcludeFoldersFromDeployment
element (or both) in the PropertyGroup element. In each element, you
can specify a single name, or you can specify multiple names delimited
by semicolons (;), as shown in the following example:

How to publish a folder containing some necessary files inside a project

I am going to publish a C# windows form application project.
I have a folder named "Reports" Containing some report file.
when I publish the project , my application cannot find the path of reports.
How can I publish my Reports inside the project?
From solution explorer, choose each file that you need to include in the publish and in the properties of the file set Copy to Output Directory to true. This way your files will be included in bin\debug folder of your application in their current folder names.
Then if you want to use Publish command, go to properties of the project, in publish tab, click on Application Files and check Show All Files and change the Publish Status of the files you need to Include.
Pay attention, if your file's Build Action is Embedded Resource then you don't need to do anything else to include in the publish because it's included (embedded) in resources of your application.

app.exe.config file not published with ClickOnce application

I have a clickonce app that needs the app.config file deployed.
In Visual Studio, if I right click on the app.config file and select properties then change the Build Action to Content, the app.config.deploy file gets created, but there is no app.exe.config.deploy file.
I really don't even need the app.exe.config.deploy file and I don't know why Visual Studio (2010) includes it.
At this point, I click on the properties for the clickonce .csproj file, click on the publish tab and click on Application Files. "app.config" and "app.exe.config is set to "Include (auto)". But I don't have the option to disable the app.exe.config.
The reason I need app.config deployed is because I'm using the following code:
var str = ConfigurationManager.AppSettings["oem"];
I'm deploying multiple versions of this with an external build script. The build script swaps out different versions of the app.config for each different published version of the code.
Bottom line question. Is there a way to either:
Get the app.exe.config to deploy with the rest of the publish
Only get the app.config file to deploy (without the app.exe.config)
If I add say a text file to the project and set it's deployment type to "content" as specified above it gets included.

Include config file after publish with WiX

Scenario:
I have two applications, a Windows Forms App and a Windows Service App. The two applications work together, use same libralies (dll) and share the same configuration file (this file is not the app.config but a custom file).
Complications:
I have a website (webforms) where the user will enter information about configuring the software, this information will be saved in the database and from this information will be generated the configuration file. The site should generate build the project with the new configuration file and the page responds to the client's request with a link to download the .msi.
Problem:
How to generate an installer from a command line to be called by the web application after generating the configuration file. I researched and found the Windows Installer XML (Wix), but it seems to be necessary to compile the entire project every time someone downloads. It's possible leave the program compiled and only add the configuration file after?
Apretiate any helps
Light (the linker in the WiX Toolset) has a feature called "cab cache" which will re-use the cabinet files which are embedded in the resultant MSI. You would use the arguments -reusecab and -cc to enable this.
You'll still have to re-build the MSI when the user submits your form, but the build will be faster (cabinet generation is usually the longest part of the build process).

How to add external file outside the application folder to clickonce deployment (winappliction.net) [duplicate]

I've got an application that I'm moving over to ClickOnce and the app has a moderately sized data folder with hundreds of files that I need to inlcude in the deployment. The folder needs to be in the same place relative to the EXE after deployment. I've seen several suggestions on how to do this but there doesn't seem to be a agreed upon method for doing this.
Any suggestions would be great -
Thanks!
One good way of doing this is:
Create a folder under the app in VS name e.g. "datafiles"
Add all files to that folder using Add as link in the dialog box after selecting Add existing item on the folder
Mark all files as Copy if newer (Copy to output directory property)
Make sure the build action is content
--> when you publish the files will be put in that folder and be a part of the application installation
Good luck!
After deployment, all files marked as data are placed in the ApplicationDeployment.DataDirectory folder. I know of no way to change this. You could copy the data files during the first run of your app, but this approach will not survive any upgrades that include data file changes.
Alternatively if you have control over the location of the data folder during development, you can place in the same relative (to the app folder) location as will be specified after deployment.
https://msdn.microsoft.com/en-us/library/kzy0fky2.aspx
https://msdn.microsoft.com/en-us/library/6fehc36e.aspx
These two articles provide methods of doing this. Between the two of thing you can find one that works for you. The one that worked for me was:
With a project selected in Solution Explorer, on the Project menu,
click Properties. Click the Publish tab. Click the Application Files
button to open the Application Files dialog box. In the Application
Files dialog box, select the file that you wish to mark as data. In
the Publish Status field, select Data File from the drop-down list.

Categories

Resources