I'm using VS 2010 to build the deployment package for a web application. I manually deploy it to the IIS 6.0 server using the deployment ccommand script it generates. All the stuff gets copied under the Inetpub default website properly. The only issue I have is that the folder permissions keep getting reset once I deploy.
Say my website is under the folder "Mywebsite". I grant certain user XYS full control to this folder. All is well. The next time I deploy, user XYZ no longer has full control and the permissions gets reset.
If you want to skip ACL operations then you need to set a property in your build. You can do this in two ways
Edit your project file
Create a .wpp.targets file
I would recommend #2. For this case create a new file in the same directory as your project file with the name {ProjectName}.wpp.targets where {ProjectName} is the name of your project. Then inside of this file you should place the following contents.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">
<PropertyGroup>
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
</PropertyGroup>
</Project>
Here you are setting the property IncludeSetAclProviderOnDestination which will signal the Web Publishing Pipeline to not include ACL providers in the manifest that is created for the package/publish.
If you want to take approach #1 just throw in the entire under the elment.
Related
I am using Visual Studio 2017 to develop and publish an ASP.NET web app using Web Deploy against IIS. My web app assembly is signed, so my project contains a .snk file in the root folder. When I deploy the web app to the server, the .snk file is sent over as well.
I imagine this is not a good idea, as the .snk contains a private key that must be kept secure. I don't like the idea of having copies of my .snk file scattered over various web servers. As far as I understand, Visual Studio should use this file to sign my assembly when the solution is built, and not deploy it to the server.
Am I correct? If so, how can I stop Visual Studio from deploying this file to the server?
I had a similar issue when publishing in Visual Studio 2019 but found that the SNK file had been added to the web project with a build action of "Content".
Simply editing the SNK file properties and changing the "Build Action" from "Content" to "None" prevented it from including the Strong Name Key file in the published folder.
Unless specified otherwise, an SNK file is not served by IIS as a valid MIME type. When someone types the url to the file in the browser they will get a 404.
If you do not want it send to the server in the first place you can also delete it from Visual Studio Explorer, but still keep the file in the folder (note that VS will delete the file also, so you need to copy it to the folder again manually in Windows Explorer).
A cleaner solution would be to create a wpp.targets file and specify the files/folders for exclusion in the publish.
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/advanced-enterprise-web-deployment/excluding-files-and-folders-from-deployment
In your case the file would look something like this: MyProject.wpp.targets
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ExcludeFromPackageFiles Include="MyFile.snk">
<FromTarget>MyProject.wpp.targets</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
</Project>
My application uses NLog as a logging framework hidden behind a facade in MyLogging project. The project is referenced by a number of web sites to not make them directly dependent on NLog. After compilation NLog.config from the logging project ends up in bin folders of each site and NLog manages to find it automatically during startup. That is understandable and pretty much OK. However, editing any file within bin folder forces ASP.NET to restart the working process so I'd like to have NLog.config one folder up beside regular web.config.
Things I'm trying to achieve\avoid:
Keep NLog configuration in a single file `cause it's the same for all of my web sites
Not to embed it into sites web.config (to not trigger ASP.NET auto-restart)
Just moving the file after building projects with msbuild command is not an option because the sites are deployed to Azure (moved files won't be packaged during publishing process)
I'd like to avoid messing with post-deployment scripts and hard coding things like E:\siteroot\0
The issue is not actually NLog specific as I'd have same trouble with standard app.config files. What are my options here?
For ASP.NET applications, it's recommend to set:
"Build Action" to "content". Otherwise it won't be copied to the root folder (folder with web.config)
"copy to Output Directory" to "none". Otherwise it will be copied to your bin folder.
See:
I want to replace web.config with transformed for debug config file when running in Visual Studio( I am NOT interesting in publishing project to some output directory). I want to keep original web.config in the root of web application in TFS, but on runtime (on IIS or Cassini) I want to use transformed debug version.
The best approach that I found so far (in Use Visual Studio web.config transform for debugging and ASP.NET Web Projects: web.debug.config & web.release.config ) is to use web.template.config as a master file, and web.config as derived transformed file.
I am not fully happy with it, because developers use to consider web.config as a master file.
I have an idea to output transformed file to ASP.Net temporary files directory, that ASP.NET used for cached files.
Does ASP.NET use web.config file from temporary cache folfder?
Will ASP.NET allow to have web.config file in cache directory different to web.config in original folder?
I found a couple properties, related to ASP.Net temporary files directory.
MSBuild tempDirectory property of the CompilationSection can be used to replace root folder of ASP.Net temporary files.
ClientBuildManager.CodeGenDir Property gives access to specific folder where current cache is located.
However I could not find, how to access path of the folder from MSBuild and will it allow me to output transformed web.config to cached folder.
Any suggestions/considerations will be appreciated.
The debug and release templates of the config file are used when you deploy the application. Can you use the publish option to publish the application to another virtual directory on your machine for debugging purposes? Then, you would have the transformed config file.
I am working on an ASP.NET project in Visual Studio .NET 2010 and attempting to make an MSI installer using a Web Setup Project. I added the Primary output from the project (which seems to pull in the relevant dependencies) and the Content Files from the project (which pulls in the Web.config and the .svc files).
The issue is that rather than applying the XDT transform and creating the Web.config using the Web.Release.config, it just copies the Web.config, the Web.Release.config, and the Web.Debug.config into the installer without doing any transformation at all.
How do I get it to apply the Web.config transformation before creating the installer?
I found a workaround that works for me:
Create needed configurations (Dev,QA,Production etc.) and associated web config transformations.
Use notepad or other text editor and include following in your web application project file (.csproj file) before tag (near the end of the project file):
<Target Name="AfterBuild">
<TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="Web.Transformed.config" />
</Target>
Do not include Web.Transformed.config in the web application project - if you do visual studio will alert you about the changes after every build which is pretty annoying.
In the web setup project:
select Content files - > Exclude Filter and add Web.config (and all other Web.*.config files containing transformation rules).
In the web setup project:
select file system editor icon -> web application folder -> Add File
and select Web.Transformed.config in the root of your web application project folder.
In the same screen: right click Web.Transformed.config and rename it to Web.config
Now you are able to generate .msi files with selected configuration and root web.config file is transformed!
Please note that this does not affect web.config files in the sub folders.
The answer ended up being located on another SO post which I missed when I was searching through before asking because it wasn't exactly what I wanted:
MSBuild Script and VS2010 publish apply Web.config Transform
A co-worker suggested using that to place the transformed Web.config in the project's bin directory and a Web Setup Project configured to grab the Web.config out of the bin directory and put it in the installer. This ended up being the most workable solution without installing any add-ons into Visual Studio.
You have to make a deployment project (I think this is a separate download), then your Web Setup project take the precompiled output of the deployment project as it input. One neat thing is that you can have it change a section of your Web.config when it builds.
This is the error I get:
Error 101 Could not load type
'control'. /Test.vbproj/x.ascx 1 1
WebDeployProject
This is a left over file that was part of the project last week, but one of the developers deleted it from the project. I have to manually delete the file in order to get the WDP to build. Is there a way to tell the WDP to ignore the files that are not part of the project or to see that these files are not part of the project and delete them?
You'll need to use your source control tools to find and remove local files that aren't under source control.
For instance, if you're using TFS, do the following:
Open Source Control Explorer (View -> Other Windows -> Source Control Explorer)
Right-click on the path in TFS that corresponds to your local working copy and select Compare
Use your TFS path as Source Path and your local working copy as Target Path
Under View Options, select "Show items that exist only in target path"
You've now got a list of all the files that exist in your local working copy but aren't in source control. For each file, either delete your local copy or add it to source control.
It could have something do to with the type of web project is it.
If it's a web site, then the compiler will attempt to compile every file in the folder. However, if it's a Web Application Project, then it will only compile those that you've specifically added as part of the project.
If you have recently deleted/removed a file from your project then you need go to Project > "Show all files" and all removed files will apear in your solution explorer. You can delete the file, /x.ascx and rebuild your WDP.
It has nothing to do with the type of Web project: http://amiraryani.wordpress.com/2008/11/06/web-deployment-project-aspparse-could-not-load-type/.
A Web Site itself considers files under its root directory as part of the site.
A Web Application Project itself allows you to customize build actions, etc. on a per-file basis.
A Web Deployment Project, however, will try to include files under the root directory (a la a Web Site), even if the WDP is associated with a WAP. That's why it doesn't matter which kind of Web project it is.
EDIT: To clarify, it would matter what type of Web project you are using if you were trying to Build, Debug, or Publish that project itself instead of using a WDP.