Use StyleCop in Rider - code-formatting

I have some questions:
Is is possible to use StyleCop.Analyzers is Unity Rider project? Or unity project is not .NET core project?
Where should i put Settings.StyleCop file to override standart rules?

Add script to Editor folder
Add dlls with custom analysers to "RoslynAnalyzers" folder in the solution root.
Follow full discussion here https://github.com/vad710/UnityEngineAnalyzer/issues/27

Related

Compile Sass Files in .NET Core

I am trying to add Sass files to my .NET Core application in Visual Studio 2017. However, I cannot find any way to compile .scss files once I've made them. I sifted through NPM and Bower, but neither offer support for Sass.
The Microsoft documentation for adding Sass (https://learn.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa) is outdated, and assumes that the project has a package.json file. Any guidance on enabling Sass compiling for my project would be much appreciated.
The easiest way to add .scss to your ASP.NET Core apps is by going to the Nuget Package Manager and installing LigerShark.WebOptimizer.Core and LigerShark.WebOptimizer.Sass.
After that, you can just put
<link rel="stylesheet" href="~/css/site.scss" />
in the head of the _Layout.cshtml file and the LigerShark.WebOptimizer.Sass package will compile all of your sass files automatically.
Use this extension for Visual Studio https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebCompiler
This extension not only lets you manually compile SASS/SCSS files to CSS, but it also adds a compilerconfig.json which can recompile your CSS every single time you click save.
Additionally, this extension can compile on project build via a nuget package it can install into your project. Which also enables CI/CD support.
This is by far the easiest way to add SCSS/SASS compilation to an ASP.NET Core Project when working inside of Visual Studio.
Try the article How to use Sass in ASP.NET Core 2.0 MVC
If I understood correctly, you can create a blank project.json with node package manager. And you can also configure auto build event with grunt.
Or better yet, follow this tutorial and manually add the file project.json to the project:
https://learn.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa
(retired doc page, now redirects to fontawesome)
Seems that you have missed this part (that file should be created manually):
If you want SCSS compilation and bundling in one simple tool, try NBundle. (Apologies for the shameless self-plug!)
You specify which files to monitor (wildcards allowed) and the tool can be used to generate compiled and bundled files in a one-shot or "watcher" mode where output files are generated when the source files are saved.
How to accomplish this might depend on your workflow. I'd like it to be part of the build process as seamlessly as possible. So my prefered solution is using a dotnet tool called excubo.webcompiler(no I'm not affiliated in any way with the author). If you install it as a project tool
dotnet tool install Excubo.WebCompiler
you can add a simple target to your project file.
<Target Name="CompileStaticAssets" AfterTargets="AfterBuild">
<Exec Command="dotnet webcompiler -r wwwroot" StandardOutputImportance="high" />
</Target>
That will use the default settings which will often be sufficient. If not you can tweak the process using a configuration file
You simply need to add a package.json think you getting confused with project.json which was the old project system for .net core projects prior to switching back to .csproj
You can use live SASS compiler for compiling SCSS to CSS when the build occurs.
You have to add few line in the .csproj file and prior to that install live sass compiler from npm.
Here is my blog post: How to Use SCSS with ASP.NET Core 5.X or 3.X

project.json in ASP.NET 5 and MVC6

When I looked at the tutorials of MVC6, I get confused the usage of project.json. By my understanding this file is used to specify the project dependencies.
Prior to ASP.NET 5, we use nuget to manage the dependencies. But from some limited MVC6 samples I have seen I don't see people mention package.config any more.
Please help me to understand:
Do we still use nuget to upgrade all depending components?
Or we have to modify the project.json manually?
By my understanding [project.json] is used to specify the project dependencies.
Yes. One of the main functions of project.json is to manage server-side dependencies. (It also specifies other project specific settings.) See the project.json file for more info.
Prior to ASP.NET 5, we use nuget to manage the dependencies.
Yes again. And, ASP.NET 5 still uses NuGet to manage dependencies. The configuration differs though. Instead of using packages.config we use project.json > dependencies to list our project's NuGet packages (and other local dependencies.)
...from some limited MVC6 samples I have seen I don't see people mention package.config any more.
Yes again. Instead of package.config, ASP.NET 5 lists all dependencies, including NuGet packages, within project.json > dependencies. These dependencies can be NuGet packages, local assemblies, or local projects.
To expand on this, in Visual Studio, the References folder is a reflection of our project.json > dependencies section. What we add to the one will appear in the other. See server-side dependency management.
In some ways, you can think of the References folder as a GUI view of project.json > dependencies. For instance, here is a dependencies section from one of my projects alongside the References folder.
Note the one-to-one correspondence between what is listed in project.json and in the References folder (ignore the fx/ stuff that isn't in dependencies).
Note the the icons beside the items that References lists. These indicate whether the reference is a project, NuGet package (blue), or assembly.
Do we still use nuget to upgrade all depending components?
Yes. We just use it differently. If we add a NuGet package to our project.json - either manually or via the GUI's package manager - then we will restore/update those using the NuGet feed.
Or [do] we have to modify the project.json manually?
No. You can modify project.json manually but there are two mains ways to add NuGet packages. Which you use is personal preference.
Edit the project.json file manually.
Use the Visual Studio GUI.
Use the Visual Studio Code GUI.
Importantly, what you do to via the GUI will be reflected in the project.json file, and what you do to project.json > dependencies will be reflected in the GUI.
Do we still use nuget to upgrade all depending components?
The short answer is yes.
We have to modify the project.json manually?
You could also do that.
You can really do anything you want:
You could use the nuget package manager UI.
You could use nuget CLI through the Package Manager Console.
Or, you could even add, remove, change dependencies by modifying the project.json which has a really nice auto-complete like in the Package Manager Console.
The only difference now is that there isn't any mention of the installed packages in the project file (previously *.csproj), so yo don't have to add the references manually like when we had the packages.config.
Do we still use nuget to upgrade all depending components
No, you can just add them by your hand with the versions. Most of the IDEs and code editors has support for nuget dependency auto-complete inside project.json file.
More info on project.json file: https://github.com/aspnet/Home/wiki/Project.json-file (could be a little outdated).
More info on DNX dependencies: http://docs.asp.net/en/latest/dnx/overview.html?highlight=project#dependencies

MSBuild: (WebDeploy) Web package creation for selected web projects

I managed to get TFS 2010 to create Web Deployment ZIPs (WebDeploy).
Now the issue is that I have multiple Web projects in the solution and packages are being created for all web projects.
In the projects that I do not want a package, I uncheck the "Create deployment package as a zip". I thought this will prevent MSBuild from creating a deployment package.
BTW I am passing "/p:DeployOnBuild=true" to MSBuild.
Is there a way to get MSBuild only package selected projects and not all Web projects?
Thanks.
Ok. Found the solution. Many thanks to Vishal Joshi for this post.
Extract from the post:
"
Deployment for Web Apps is feasible at both Solution as well as Project build level although when it comes to Solution Build then you might want to make sure that the properties you are passing at Solution level will apply to all the projects in the solution which might not always the outcome you desire. In that situation all these properties can be set within the .csproj or .vbproj files too. You can do that by unloading your project file and in the top <PropertyGroup> section just add above properties as you like:
For e.g /p:DeployOnBuild=True can be added as <DeployOnBuild>True</DeployOnBuild>
"
So, the solution was to remove /p:DeployOnBuild=true from TFS Build process template and update only the project files that require a package.

tfs build craeting wrong AppManifest.xaml

I created a automated build in tfs for the silverlight project. my project uses prism and so it has many xap created. but the AppManifest.xaml in the main xap file is wrong. it is using AppManifest.xaml of some other module(XAP file). Can anyone explain why this wil happen
This sounds like an MS BUILD configuration issue. Can you post your .proj file? I am guessing you have something configured incorrectly- that is the only way this would happen.
The probelm is, as the silverlight projects in the solution are building randomly, so it picks the manifest.xml of the project which is currently building and create a xap file.
So the solution is creating dependencies between sivelright projects. so that it will build in a certain order and there will not be any confusion of manifest

aspnet_compiler and msbuild.exe

I am pretty new to msbuild and aspnet_compiler.
I am using aspnet_compiler to compile web application project. Now I just saw the MSBuild.exe and noticed that its builds my website into the /mywebsite/precompiledWeb folder. Now why do I need to use MSBuild.exe? Can't I directly use the aspnet_compiler to see if my website can be built properly?
(Not sure if I explained it very well).
msbuild.exe is usually used to build projects and its dependencies. When you have a web application project with a project file, vs can use this to build not only your web project but all the dependencies involved. This would only build your source code files, not the markup files (.aspx,.ascx,.etc).
aspnet_compiler is meant to build a web site project that doesn't have a project file. This said, you can also use it to make sure your markup files are also built for your web application project.
You are correct you can manually invoke the aspnet_compiler.exe tool. But better would be to use Web Deployment Projects to help you do this.