Suppress warnings/errors in Visual Studio 2017 for certain file - visual-studio

I have a project which is using TypeScript and some external libraries.
I'm searching a way to block all errors and warnings for all .js, .ts, .d.ts etc. files in node_modules folder and the folder with other libraries which relative path to the project root is assets/plugins . I've tried creating a .eslintignore file with the following content:
./node_modules/*
./assets/plugins/*
and also
./node_modules/**/*.js
./node_modules/**/*.ts
./node_modules/**/*.d.ts
./assets/plugins/**/*.js
./assets/plugins/**/*.ts
./assets/plugins/**/*.d.ts
but this didn't work.
Just to recap, I want to block errors and warnings for those files only and remain visible for all other files in the project.
P.S.: All those errors and warnings in .ts and .js files are visible only in Visual Studio 2017 when the project is opened in Visual Studio 2015 there are no errors and warnings.

Adding an .eslintignore to the root of the project, containing the following, and then restarting VS did the trick for me (for now at least)
**/*.d.ts
**/node_modules/*

In order to suppress all warnings for node_modules (both ECMAScript and TypeScript) you should create an .eslintignore file with the following content:
**/*.d.ts
**/node_modules/*
**/assets/plugins/*
and also create configuration for the typescript compiler (tsconfig.json file) in the project root containing the following:
{
"exclude": [
"node_modules/*",
"assets/plugins/*"
]
}

Related

How to ALWAYS include new files in a folder in Visual Studio 2017

I have a project in visual studio 2017 for making a WinJS UWP windows 10 app. I'm using babel to compile some files from one folder and put them in another -- > jsx/src includes my .jsx files, and they get compiled into jsx/out.
I've set up a babel watcher to watch the jsx/src file and output a new file to jsx/out, but for now every new file I add, I have to manually add it in visual studio so that it shows in the folder. I'd like this to be automatic.
I have the answer for this now! Didn't realize this was left unanswered.
The answer is to modify the project.jsproj file directly. Open your project folder, find the file called {projectname}.jsproj and open it in your favorite text editor.
For my use case, I wanted to:
Fully include the 'bundle.js' file in /jsx/out
Include, but not export with the build, any .js / .jsx files in /jsx/src
So I added these lines:
<None Include="jsx\src\**\*.jsx" />
<None Include="jsx\src\**\*.js" />
<Content Include="jsx\out\bundle.js" />
"None" means the files are shown in Visual Studio, still remain debuggable, but don't end up getting put in with the files when you build it for the windows store.
Now any new files get included in when they're added to the appropriate folder (sometimes you might have to force reload the project to see them)

Payload contains two or more files with the same destination path

I created a new UWP MSTest Project and I added a reference to my main application. When I build the solution, get the an error:
Payload contains two or more files with the same destination path
Along with the conflicting files. I checked the copy to local for the files and they are set to Do not copy. Here's a sample of the error messages:
Severity Code Description Project File Line Suppression State
Error Payload contains two or more files with the same destination
path 'Assets\Square44x44Logo.targetsize-24_altform-unplated.png'.
Source files:
C:\Users\joe.nuget\packages\newtonsoft.json\11.0.1-beta1\lib\netstandard2.0\Newtonsoft.Json.dll
C:\Program Files (x86)\Microsoft SDKs\Windows
Kits\10\ExtensionSDKs\TestPlatform.Universal\15.5\Redist\CommonConfiguration\neutral\Newtonsoft.Json.dll App.Test C:\Program
Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets 1747
Error Payload contains two or more files with the same destination
path 'Assets\Wide310x150Logo.scale-200.png'. Source files:
E:\App.Test\Assets\Wide310x150Logo.scale-200.png
E:\App\Assets\Wide310x150Logo.scale-200.png App.Test C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets 1747
This happens when the content file names are the same for the app itself and the test project. Even though you set them to Do not copy, they are still conflicting during the intermediate step of building the test project.
The simplest solution is to rename or delete the Asset PNGs inside the Test Project so that they do not conflict with your app itself.
Newtonsoft.Json
Problem with Newtonsoft.Json is a known issue that has been reported to the Visual Studio team and the fix is now pending release.
The only workaround mentioned is the following by Morten Nielsen:
As a workaround and if you can live with the v9 version the test
project ships with, you can add a direct assembly reference to the
Json.net lib that they use, instead of using the nuget reference.

Prevent Visual Studio from deleting output files from referenced projects

I've got a Class Library project and a Console project. Inside the Class Library project there's a folder called "ConfigSettings" containing a configuration file that's referenced by the App.config file. Its "Copy to Output Directory" is set to "Copy Always".
The Console project references this Class Library project. When the console project is built, the ConfigSettings folder is created in the correct place along with the external config file. However, every time I Debug the Console project, the external config file is deleted. The ConfigSettings folder however is left untouched. If I mark the file as read-only it is not deleted, and warning appears in Visual Studio's Error List:
Warning Unable to delete file "C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config". Access to the path 'C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config' is denied.
Is there a setting I can change that will prevent VS from removing this file when I Debug the project? I am using Visual Studio 2015.
This might not be the best solution possible, but I found here, if you do a "Clean solution" just before executing your solution, the files will remain.

Why does Visual Studio publish packages.config too?

When I use the option Publish... selecting as target the file system in Visual Studio 2015 it compiles the code, do the XML transformation in the Web.config files and copy the files to the folder I specified.
It does not copy any *.cs file as expected since it is compiled.
Something that I don't understand is why it publishes the Nuget Config file (packages.config), after all, the files needed are already in the bin folder.
I found this question that says how to avoid but not the reason they decided this file would be usable on the server.
Can I stop VS from publishing packages.config?
Anyone know why packages.config end up in the publish folder?

The TypeScript Compiler was given no files for compilation, so it will skip compiling

When i am trying to Build my default JavaScript project(BlankApp Apache Cordova) in Visual Studio 2015 preview am getting following error.
The TypeScript Compiler was given no files for compilation, so it will skip compiling.
Steps Taken in visual studio 2015 preview:
File -> New -> Project -> Apache Cordova apps(under Javascript templates).
Run the default project with Android Emulator.
Getting the following error.
Warning 2 The TypeScript Compiler was given no files for compilation, so it will skip compiling. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets 97 5 BlankCordovaApp4
This is a known issue in the CTP3 release. It sounds like you've created a JS-based project, and have not added any TypeScript files, and so of course there are no .ts (aka TypeScript) files passed to the compiler. Ideally the compiler wouldn't be run at all, but the warning is harmless, and everything else should otherwise be working.
You need to make sure that at least one of your TypeScript files is marked with the TypeScriptCompile build action.
If you click on the file and check the properties window in Visual Studio you will see the build action - it may be that they are all set to some other action.
Option 1:
Take Project offline, edit project, remove the following lines:
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')"/>
and
<Import
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets"
Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')"
/>
Option 2:
Change "AddTypeScriptReferencePath": true to false in Webessentials-Settings.json
It seems that there is no type script file available to compile. add a blank type script file under script folder and then compile, it should work.
This warning was driving me nuts with ASP.NET 5 (asp.net core 1). If you double click the warning you open the Microsoft.TypeScript.targets file. Delete the line with CompileTypeScript and the warning goes away. I'm assuming this prevents TypeScript from compiling normally, which is fine by me as I don't want it anyway.
<PropertyGroup>
<CompileDependsOn>
CompileTypeScript; <--- delete this line
$(CompileDependsOn);
</CompileDependsOn>
I had the same issue.
Mine was due to missing system variable to nodejs. Check your visual studio output. If it is not recognizing “node” command, add system variable.
Computer->right click-> properties -> advanced system settings -> Environment Variable
Check “path” under user variables and system variables
Add the nodejs path to it. Ie: C:\Program Files (x86)\nodejs

Resources