TypeScript - Purpose of bin / obj folders - visual-studio

Do I need the bin / obj folders for TypeScript project? If so, can you please explain what they are for (for TypeScript) and tell me how to use them?

Seems like Visual Studio simply uses ASP.NET project structure for TypeScript projects. There is no use for these folders (or for the web.config file) if you are writing pure, client-side TypeScript.

Related

Angular 2 beta typings in Visual Studio (ASP.NET 4)

In the alpha versions of Angular 2.0 I worked with the files from DefinitelyTyped to use typings for TypeScript in Visual Studio. This was simple by just adding the d.ts files to the project. In the current beta stage this seems to be different since DefinitelyTyped no longer provides this file and they have been moved to the angular repo directly.
Problem is that I don't know which file to include to the project in the first place, including all of them throws tons of errors while compiling.
My setup is a DNN website with my VS project residing in the DesktopModules folder, meaning that my project is not the root of the website. I use SystemJS to load components from various locations within this site.
Is there a simple way to include one d.ts file or compose it so that TypeScript can compile correctly?
EDIT - To explain it more detailed:
When I was using import statementimport * as ng from 'angular2/angular2' in the alpha, the 'angular2/angular2' (path and JS file) was resolved by SystemJS and Visual Studio knew about it because of the definition file that was declaring a module. How do I achieve that Visual Studio will know about that again? I tried many hours without success, except using the old Alpha stage .d.ts file and changing it slightly to declare it as angular2/core.
How can this problem be resolved without using the new project system of ASP.NET 5?
Since TypeScript has introduced the "exclude" section in tsconfig.json the preferable way of setting up project is instead of manually including every file that is a part of your project using "files" section of tsconfig, you exclude unwanted ones and everything else will be automatically considered part of your project.
Angular2 comes with typings as its part. You no longer need to manually add them via tsd/typings. Your IDE should be able to automatically resolve them.
Make sure though that you will exclude at least "node_modules" folder in tsconfig.json so compiler will not try to compile its contents and you will not end up with tons of "duplicate identifier" errors.
For more details you can follow sample walkthrough specifically for VS: Starting Angular 2 in ASP.NET 5 with TypeScript using Visual Studio 2015
I came up with a very simple solution. I can accept this workaround because it is only needed at development time.
First of all, in order to make all the magic work you have to use the GitHub source code of DNN and include your projects to the solution.
For Visual Studio to find the typings I just copied the angular2 folder from my JSPM location to the root of the website (rxjs is needed in addition). In this case the statement import * as ng from 'angular2/core' will let Visual Studio search in the root of the website for a folder called angular2 and a file named core. By doing this, everything is compiling fine, all errors are gone and IntelliSense is working again.
This is no problem at runtime because all script files are loaded through SystemJS from the location where your JSPM packages reside (in other words those newly copied folders are not needed, it's just for VS to find the typings).
I also wanna mention that this no problem with Angular itself, TypeScript just does not know anything about JSPM and therefore can not find the right location to load the typings from. There is a discussion on the TypeScript repo on GitHub which can give you more details on that. In future versions there could be a way to tell TypeScript some paths to lookup, or maybe even an integration of JSPM and TypeScript.
https://github.com/Microsoft/TypeScript/issues/6012
I have found that the real important include in VS is the typescript.d.ts file. This is in the node-modules\typescript\lib folder. I also include the js files in the index.html, but that is only to get rid of the red squigles.

Visual Studio 2012 - How to assign multiple build actions to a TypeScript file

I am using Visual Studio 2012 to create a class library project that will also include a number of TypeScript (.ts) files, as well as their generated .js and .js.map files. All of these files need to be included in the assembly as embedded resources, so that they can be exposed to a consuming ASP.NET MVC application via a custom VirtualPathProvider.
Note: although only the generated JavaScript files are essential for the production environment, the .ts and .js.map files must also be accessible to the web application, for debugging.
This presents a conflict, since TypeScript files are usually assigned the TypeScriptCompile build action but I also need them to be assigned EmbeddedResource.
Is there any way to assign multiple build actions to a VisualStudio project component? Alternatively, is there another way to get TypeScript to compile files that are not explicitly marked as TypeScriptCompile or to get Visual Studio to embed files that are not marked as EmbeddedResource?
Thanks for your suggestions,
Tim
If you had a TypeScript file that referenced all of the others, only it would need to have the TypeScriptCompile type as the compiler should walk all the dependencies and compile all the rest too.
So creating a file that acts as the compilation target and that references all of your other files might allow you to change all the rest to EmbeddedResource.

Vs2010 using log4net with Intellisense

I'm using vs2010 and I need to log a multithreading application.
So I decided to use log4net, but as I'm not used to work with this, Intellisense is gonna be worth.
I download the .xsd from http://csharptest.net/downloads/schema/log4net.xsd and put this in VSFolder/Xml/Schemas.
But, how can I say to my log4net.config to use the XSD Schema?
Use the menu XML -> Schemas...
The menu is only there if you have the config file (or any other xml file) open.
Instead of putting it into a VS folder, put it somewhere inside your solution's folder tree. It doesn't even need to be included in any projects. just put it there and it works...
Or into: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas and you're sorted once and forever.

Best practices organizing a Visual Studio solution

I need some help regarding Visual Studio solution and project organization.
I have a solution with several projects. All of them are written in C# and are compiled as libraries to be used by the GUI. Some of these libraries have also dependencies with others. For example, TestExecutive needs LoggingFramework, Communications needs LoggingFramework too.
Which is the best way of organizing? I'm thinking on a folder assemblies to hold libraries' binaries in one place. Something like:
Solution
|
|-- TestExecutive
|-- LoggingFramework
|-- assemblies
There is also another problem. One of the projects uses a native C dll. Where do I have to place this library? With the librarie's assembly or with the final executable?
EDIT:
Ok, now suppose I have the WinForms program running. I have source code and binaries mixed. Which features do I need to generate something I can distribute? I mean, with all the libraries and configuration files, but without source code. I have done this before with Nullsoft installer, but I don't know if visual studio can help you doing that.
A few things here:
When one project depends on another, you can set up that dependency in Visual Studio. Right click on a project and select Project Dependencies...
For other .NET assemblies that are NOT part of your solution (3rd party tools, etc.) I do exactly what you showed here -- I have a separate folder parallel to the projects. Then I set up the assembly reference in each of the projects with "Copy Local" set to true and it works fine.
For native C dlls, it's a little different. There is no direct reference to them in the references section of the solution explorer. The compiler isn't going to look at the dll to check your p/invoke references or anything like that. You just need to make sure the dll is part of the deployment on your top level web or winforms project. It's a content file just like a css file or image or something. Just add it as a file in the project and make sure the "Build Action" is set to Content so Visual studio knows to just copy the file as part of the deployment
I set my solution folders up a bit differently than you. At the top level I have the following folders:
\build
\lib
\src
The build folder has build scripts (NAnt, MSBuild, etc). Any 3rd party assemblies (or anything I'm not building in the solution) get put into the lib folder, in an appropriate sub-folder. For example, I'll have log4net, NUnit, RhinoMocks folders in the lib folder, each containing the files needed for that dependency. The src folder has the solution and all project files.
I like this structure because it clearly delineates between the project code and the other stuff that is required by the project. Also, I usually set up some custom build tasks to copy the resulting assemblies for my project into either a \deploy or \lib\ folder. This way you don't have to hunt in the \src\\bin\\ folder to get a built assembly or the whole project; however this seems a bit beyond the scope of your question.
Btw... I didn't come up with this structure on my own, I think I started off using Tree Surgeon and evolved my process from there.

How to stop a Visual Studio 2008 project compile from updating dependent web application projects?

I just upgraded a solution from .NET 2/Visual Studio 2005 to .NET 3.5/Visual Studio 2008.
I have a Web Application Project "W" that has a project reference to a class library project "C".
When I build "W", "C" is compiled and copied local, and all is good.
However, if I make a change to C, or build C with a different configuration, and compile ONLY C, the output is automatically copied to W's \bin directory! And in my case, this breaks W.
This behaviour seems to be specific to VS2K8 and web application projects. I'm sure someone thought it would be nice to have studio push updates forward to referencing projects, but it's a very bad idea.
Is there a way I can turn this behaviour off? I can't find a related project or IDE option anywhere.
Create a file called "Libraries" or something else appropriate and put a copy of the DLL file from your class library project into there and have the web application project reference that file, as opposed to the project.
This will allow you to modify your class project at will, but will also force you to copy things over to make sure you have the latest and greatest in your web application. In your case, this sounds like the preferred method for you.

Resources