Why does my web deployment project, when compiled, create a Visual Studio project file and a bunch of other unwanted/unneed files in the release and debug folders?
The debug files are also being included even though I have the "Generate debug information" option unchecked when in release mode.
I'm also getting some obj folder that contains another set of debug and release folders that seem out of place.
In short, it's creating a lot of non-release files. I am using a ASP.NET MVC project, but I don't think that should make a difference.
By default Visual Studio generates PDB files in both debug and release mode. The difference is that in debug mode the entire symbol table is loaded while in release mode only the key symbols are loaded.
You can completely disable PDB generation in release mode by setting generate debug info in advanced compile options to none.
If you want to have a clean output folder you can add the following ItemGroup to your web deployment project's file (.wdproj):
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\obj\**\*.*" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.csproj" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.scc" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.user" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.vspscc" />
</ItemGroup>
Related
I have a .NET Core 3 project in Visual Studio 2019. When I copy and paste a file, through Windows Explorer, into the project folder, Visual Studio automatically includes the file into my project, which I do not want to happen. Is there a setting to disable this feature?
Starting from VS 2017 project format in .NET has changed. You need to add <PropertyGroup> tag at the top of your .csproj file:
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>
Here is the complete answer to your question:
In Visual Studio, why are all files automatically part of my C# project?
Well, you can modify the known project file (.csproj for c# project), by customize the items include path that satisfied your include files specifically.
For more details, you can check these out:
https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata?view=vs-2015&redirectedfrom=MSDN
Understanding a csproj assembly reference
Including content files in .csproj that are outside the project cone
Enjoy and deploy with confidence!
I'm working on a project that was recently upgraded to Sitecore 8.2 and .NET framework 4.6 from 4.0. When I build it locally my site works, but in my testing environment, where I'm building in Jenkins using msbuild, the mscorlib dll is causing is causing a compilation error:
Could not load file or assembly 'file:///E:\inetpub\wwwroot\mysite\Website\bin\mscorlib.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
There is no reference to mscorlib in my project, as this dll is referenced automatically by the build system, so I'm not sure how to modify or update it.
The line in the MSBuild logs where it's being added:
Copying file from "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" to "bin\Release\mscorlib.dll".
Furthermore, when I build my project in Visual Studio, it does NOT copy mscorlib.dll into my bin, so I'm not sure why this is happening in the Jenkins build and not my local environment.
By default it was adding the dll from C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and I needed it to use the version in C:\Windows\Microsoft.NET\Framework65\v4.0.30319\ instead. I added a reference to the csproj file with the correct path:
<Reference Include="mscorlib">
<HintPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll</HintPath>
</Reference>
Does Visual Studio for Mac support roslyn analyzers, especially Microsoft.CodeAnalysis.FxCopAnalyzers?
The analyzer nuget packages can be added to a project in XamarinStudio/VS2017 for mac but you need to manually edit the project files to add the ItemGroup.Analyser project items linking to the dlls. These do not install on a mac as the installers are provided as custom PowerShell install scripts in the nuget packages. Note you will need to maintain the sections manually when updating the analyzer packages or removing them.
Ex: I needed to add the following to the project file, to install the Microsoft.CodeQuality.Analyzers 2.6.0 and also reload the project file.
<ItemGroup>
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
</ItemGroup>
Once added and the project is re-build I received the CA warnings from the project, and they were displayed in the standard errors pane.
I am developing a Cordova based mobile app via Visual Studio's Cordova template as well as an ASP.NET MVC web application in the same Visual Studio solution. I'd like to be able to share as much HTML between both projects as possible. One issue I am running into is the bundling and minification that takes place in ASP.NET that is not available in the Cordova project. Any ideas how I could support minification within Visual Studio across both projects that would allow me to share as much code as possible?
Cordova's project file .jsproj is an ordinary build file that is handled by MSBuild, so you can apply whatever processing logic you need by adding custom targets. You can even run tools from Node.js world like Grunt or Gulp by installing respective VS extensions.
As to sharing code between ASP.NET and Cordova projects, I suggest adding links in your .jsproj, as follows:
<PropertyGroup>
<AspNetProject>C:\YourAspNetProject</AspNetProject>
</PropertyGroup>
<ItemGroup>
<Content Include="$(AspNetProject)\Views\**\*.cshtml">
<Link>views\%(RecursiveDir)%(FileName).html</Link>
</Content>
<!-- add other links here -->
</ItemGroup>
This way VS displays the linked files in Solution Explorer and allow you to edit them as if they were local.
Unfortunately, the current version of VS Tools for Apache Cordova, CTP3, does not support linked items, so another change has to be made in your .jsproj:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CordovaTools\vs-mda-targets\Microsoft.MDA.targets" />
<PropertyGroup>
<BuildDependsOn>PreBuild;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="PreBuild">
<ItemGroup>
<LinkedFiles Include="#(Content)" Condition="'%(Content.Link)' != ''" />
<!-- add other links here -->
</ItemGroup>
<Copy SourceFiles="%(LinkedFiles.Identity)" DestinationFiles="%(LinkedFiles.Link)" />
</Target>
The PreBuild task is called before any Build subtask and copies the linked files to your Cordova's project. The rest of the build process runs as usual.
I have MVC 5 application which is using RazorGenerator.MVC and RazorGenerator.MsBuild. Because of that my MvcBuildViews is set to false, because it is no longer required. The application is .NET 4.5 one in Visual Studio 2012.
When I'm publishing my application with web publish tool (right click on MVC project -> Publish), I'm using option to pre-compile during publishing.
Everything is working very well when I'm using Any CPU or x32 Platform. However when I'm trying to publish x64 application I have an issue with aspnet_compiler.
It is always trying to use: *C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe* one instead of 64 version so my application cannot be published with x64 platform.
The only place I found I can change path is under MvcBuildViews target, but becuase it is always false for me it will never hit this target and AspNetCompiler ToolPath cannot be used.
I'd like to know from where (which targets file or tasks file) contains that path? I've searched all targets I believe and couldn't find from where is taken.
Open the csproj file of the project in your favourite text editor.
Locate:
<MvcBuildViews>true</MvcBuildViews>
Add the following below it:
<AspNetToolPath Condition=" '$(Platform)' == 'x64'">$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
Locate:
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'" >
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
Amend the AspNetCompiler line as follows:
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" ToolPath="$(AspNetToolPath)" />
For Visual Studio 2013, the solution can be found here: Configure Visual Studio 2013 to allow ASPNETCOMPILER to precompile using the x64 compiler (thanks to Nitin)
Shortcut:
Add the following xml in the Project/PropertyGroup xml tag to the publish profile (located in the Properties\PublishProfiles directory of your project).
<AspnetCompilerPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>