Wix - WebProject - Add a file in the installation folder - asp.net

I have n wix installer for a webproject (asp.net). This installer relies on msdeploy, so my website content is wrapped up in a zip file and this file is used for installing at the target. I'd like to include a TXT in the instalation directory, but I can't add this file into the web project solution.
Any idea of how to achieve that?

You can create a custom action to do the job for you.
try that:
<CustomAction Id="ConfigCommand" Property="Cmd" Value="[SystemFolder]cmd.exe"/>
<CustomAction Id="YourActionName" Return="check" Property="Cmd" ExeCommand="/c copy [#README.txt] [INSTALLDIR]\README.txt " />
<InstallExecuteSequence>
.....
<Custom Action="ConfigCommand" After="SomeActionBefore"></Custom>
<Custom Action="YourActionName" After="ConfigCommand"></Custom>
</InstallExecuteSequence>

Related

Cannot read web.config file Asp.net core web application

I am trying to run some sample code for ASP.NET Core and Angular 2.
I cloned the project from https://github.com/PacktPublishing/ASPdotNET-Core-and-Angular-2 and changed the sdk version in the global.json to the current version I have installed (1.0.0-preview2-1-003177). When I run the web application I get the following error page:
I grepped the project looking for the config file path but came up with nothing. I also contacted support but they aren't helpful.
Does anybody know how to change the config file path?
You must open hidden .vs folder in root of your solution folder, then find applicationhost.config file in the config folder.
... and change
<virtualDirectory path="/" physicalPath="......"
to the proper path.

How to avoid my own nuget package overwrite the target project web.config and global.aspx file when they install my package

I was created one nuget package using following step.
First I created one Asp.net Mvc application
The I created spec file using nuget spec command
Then I edited $id$,$version$,$author$,$description$ ect..
Then I created package using following command.
nuget pack myproject.csproj -Build -Properties Configuration=Release
It was created one myproject.1.0.0.0.nupkg
Then I copy the file And past into C:\LocalNuGetFeed\myproject.1.0.0.0.nupkg
I already configure the local repository in my VS
My problem is
When I install this package from any other project it ask following question.
But as per my requirement I don't want to move this file to target project. Suppose user give y the it overwrite the target project file because of it i face lot reference problem.
**File Conflict
File 'Web.config' already exists in project 'CRM'. Do you want to overwrite it?
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "N"):
File Conflict
File 'Global.asax' already exists in project 'CRM'. Do you want to overwrite it?
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "N"):**
But in my package I don't want to move this above two file from package to target project.
Is any way to avoid transform Global.asax and Web.config move from package to target project.
In my .nuspec file I added following line
<files>
<file src="Web.config" target = "" exclude="Web.config"/>
<file src="*.asax" target = "" exclude="*.asax"/>
<file src="Content\*.css" target="Content\" />
<file src="Scripts\*.js" target="Content\Scripts\" />
</files>
But it include the web.config file AND Global.aspx file in Content folder My resultant package look like bellow
myproject.1.0.0.0
>> Content
....css
>>Script
..Js file
web.config
Global.asax
I was solved this using following command to crate package
nuget pack CrmHtmlController.csproj -IncludeReferencedProjects -Exclude **\*.config;**\*.asax
so it exclude all .congig and .asax file from package.
Take a look at your .nuspec file. It's just an XML file, so you can open it up with any text editor. See how it define which files to include at <package><files>? Remove those files that you don't want. A handy tool if you want to do this with a GUI is NuGet Package Manager.
Nuget includes the web.config in your package, because the build action of the web.config is "Content". This is by default and necessary for a classic publish of an asp.net web site.
If you don't want this, propably because your assembly is only a component of another web site, you can change the build action to "None" and nuget will not take it any longer.

Removing comments from web.config on build

Is it possible to remove the commented lines from a web.config on build?
xml transform is fine to remove some elements but I couldn't find any syntax to clean the comments from the file.
We are using TFS 2010 build server for our builds.
<add xdt:Transform="RemoveAll" xdt:Locator="XPath(//comment())" />
Put this node within the root node of your transform file. "XPath(//comment())" selects all XML comment nodes to delete.
UPDATE: See actual and working answer below.
It's not possible to do with xml transformation.
But you can do it with your own console app or msbuild task.
See example code here Remove XML comments using Visual Studio 2010 Web Config Transformation
I had a similar problem where I wanted to remove dev comments from the config files before I published to the web site. I wrote an app that will recursively remove comments from config files in the directory I specify on the command line. The sample below assumes YourCommentRemover will do the same.
I included the comment remover project as part of my solution and referenced it in the web app I plan to deploy. You can just add the executable as a reference if you want. Since I didn't want the comment remover to get deployed, I added a task to delete it from the bin directory where it was being staged for deploy, (ProjectDir)obj\$(Configuration)\Package\PackageTmp\.
Open your project file in a text editor (You can right-click on the project file in the solution explorer and select 'Edit Project File').
Go to the very end of the project file and insert the following before </Project>:
<Target Name="BeforePublish" BeforeTargets="MSDeployPublish">
<Exec Command="$(ProjectDir)bin\YourCommentRemover $(ProjectDir)obj\$(Configuration)\Package\PackageTmp" />
<Exec Command="del $(ProjectDir)obj\$(Configuration)\Package\PackageTmp\bin\YourCommentRemover.*" />
</Target>
This target will run before any files are copied to the web application location on publish.

How To Run MSBuild scripts in .wixproj?

Im trying to learn to make a web installer using Windows Installer XML (WIX 3.5). I found this blog about using msbuild in .wixproj files to avoid the scenario where the installer ends up dropping the web project assemblies right in the root of the app instead of keeping them in the bin folder like they're supposed to be.
Here is the link to that:
<http://www.paraesthesia.com/archive/2010/07/30/how-to-consume-msdeploy-staged-web-site-output-in-a.aspx>
But after adding the MSBuild scripts in the .wixproj file, I don't know what to do anymore. According to the instruction after adding the MSBuild script:
"When that target runs, you'll see a .wxs file pop out in the .wixproj project folder. Add the generated .wxs to your .wixproj project so it knows to include it in the build."
I really don7t know what this means. How can I run the target? I tried to build it but there was no .wxs file generated in the .wixproj folder.
Am I missing something? Please help...
Assuming you have added the section from the tutorial:
<Target Name="BeforeBuild">
...
</Target>
The target will be run automatically when you build the project. The "BeforeBuild" target is one of the standard entry-points to add your own modifications to the build. The target will then generate a file (named [WebProjectName].wxs that is placed in the same directory as your wixproj file. Click on the show all files button in visual studio and right-click on the file and "Include in project" That will then include the wxs is your installer and when you next build it will have the correct folder/file structure.

DotNetNuke module development with webservices

I need to deploy a webservice as part of a DotNetNuke 4.x module that I'm creating - but am not sure how I can do that and know that it'll always stay in the same place. How can I add an asmx file to my module project, and when I create my .DNN file specify where the webservice will end up? I want to reference the webservice from inside the ascx file in the module using the "~/webservices/webservice.asmx" format.
Does DotNetNuke have a way to specify in the .DNN file where the webservices will end up on the site? And if so, will I still be able to reference them with root anchored tags like ~/myservice.asmx?
You can include the ASMX file by including a element in the <files> section:
<files>
<file>
<name>YourWebService.asmx</name>
<path></path>
</file>
</files>
Generally, you don't need to specify a path.
Alternatively, you can include a Resources.zip file with your package which will include any files other than those that DNN needs to process during installation (e.g. Assemblies and SqlDataProvider files).
The benefit of this is maintainability. Using Resources.zip will keep you from having to edit the manifest file over and over...
The contents of the zip file will simply be unpacked into the root module directory (e.g. /DesktopModules/YourModule/*). If there is a file structure within your zip file it will be maintained.
You'll want to add TheNameOfYourFile.zip To your manifest file under the element.
[snip]
<folder>
<name>Your Module</name>
<friendlyname>Your Module</friendlyname>
<foldername>YourModule</foldername>
<modulename>YourModule</modulename>
<description>A module for DotNetNuke websites.</description>
<version>01.00.00</version>
<resourcefile>Resources.zip</resourcefile>
<businesscontrollerclass></businesscontrollerclass>
<modules>
<module>
[/snip]
As for referencing it in your module - I suggest using:
<%=ResolveUrl("~/DesktopModules/YourModule/Services.asmx")%>

Resources