can ironruby nuget package be installed then used in a vanilla VS2012 - c#

I am interested in using a ruby script (https://github.com/zmoazeni/csscss) withing an ASPNET MVC site. I have no previous experience with ruby so my question could be naive.
Is it possible to import the ironruby nuget package and execute the ruby scripts?
My goal would be to put a .net wrapper around the ruby script(s) and put the output out as HTML.
So far I have tried Googling getting started with ironruby but have not found much that I understand and could get working, (yes that sound vague, but I don't know ruby or ironruby and couldn't find any good simple guides on getting started).

I've realized a simple proof of concept at https://github.com/edymtt/csscss-from-ironruby that shows in a console application how to use IronRuby to run the source code of csscss to analyze a CSS loaded from a file. To achieve this result I've started from this SO question -- you can find the additional resources I've used in the comments of the program. I haven't tried this code in a ASP.net MVC site -- anyway this sample should be a good starting point.
This solution is a bit cumbersome to maintain, since you have to manually put the sources for the csscss and its dependent libraries in the solution. An alternative solution is to install Ruby on the machine, install csscss using gem(so it download the dependencies automatically) and to invoke the program from .NET -- I'll also show this approach in the sample. Note that this solution requires that you could install Ruby on the web server.
UPDATE 2013-09-02 18:15 UTC Following the suggestion from Zach Moazeni I've been able to semplify the approach that used IronRuby to run csscss and I've updated accordingly the proof of concept. In a nutshell:
outside the .NET program I've used bundler to download csscss and json (and dependent gems) to a local folder of the project;
in the .NET program I've written a function to discover all the paths of the libraries in the gem folder created by bundler (by finding the gems folder and then including for each subfolder the lib folder, this algoritm was inspired by this SO thread);
I've passed this list of paths to the IronRuby interpreter before launching csscss.
This approach should conjugate the ability to use only .NET to run the program with the ease of the update given by gem and bundler.

I'm the author of csscss and I built the JSON output for this reason.
csscss -j file.css
It's not a perfect solution, but instead of outputting human readable text, it will output JSON that you can parse from whatever language/runtime.

Related

InstallShield - how to write custom action functions

I am trying to create installer using InstallShield and have requirement to execute some code during the installation process. Earlier I was using VS 2015 setup extension to create MSI but due to some advance needs in MSI we are planning to migrated to InstallShield and code that we were executing in onBeforeInstall / onAfterInstall of ServiceInstall also needs to be executed and as per my understanding we need to create CustomActions and for that requirement is to create functions and put them in dll file.
I tried to look into documents of InstallShield but wasn't able to find good way or example code that i can start with to write such code. I prefer to write in C# it will be helpful if some one can guide me to write function to attach with custom actions.
Help Material: The documentation included with InstallShield should have good information to get going? Installscript Reference. Also check the Installshield installation folder under Program Files - I think there are some samples there.
Installsite.org: Setup consultant Stefan Kruger's installsite.org has a number of coding examples for custom actions.
Github.com: You can search github.com to find samples of just about anything. Sample search for MsiGetProperty (used by most Installscripts).
Custom Actions: Managed code (Dot Net) has a number of technical problems for large scale package distribution. It is recommended that you use Installshield's proprietary Installscript language or straight up C++ (minimal dependency, static linking when possible). I don't have a nice summary of managed code problems, only this half-mad answer that was written some time ago.

Loading an whole Python project when hosting IronPython in C#

I've seen that there is documentation about how to execute or compile a Python script in C# by reading about Hosting approach for IronPython inside a .Net project: http://www.voidspace.org.uk/ironpython/dlr_hosting.shtml
But nothing is explaining clearly how to load an whole Python/IronPython project that contains several folders and files with a lot of import.
Is this something possible, or this approach is not appropriate for large project, and more for short scripts?

How to compile c#/c++ files from Java Application

I am just looking into compilers and I was wondering is it possible to compile both c# and c++ files from a Java Application (e.g. to compile java from a java application you can use the JavaCompiler API). I have looked online for this but all i can find is ways to compile java files from c# and c++ and not the other way around.
If so, what API's can you use for this?
If you know the system commands for compiling and executing .cpp files(don't know much about c#) you might want to check out this. It details how to execute system commands from a Java program. Pass the system commands for compiling the required file in Runtime.getRuntime().exec().
Consider learning how to call ant from Java code and using something like this ant enhancement.
Disclaimer: I don't know anything about this product, but found it by searching for "can ant build c++?"
For C# in Windows: compiler (csc.exe) is part of .Net install on Windows and can be found at well known location (like %windir%\Microsoft.NET\Framework\v3.5 for .Net 3.5). The same place also contains MSBuild.exe that can build project files (*.csproj).
Your code may need to provide locations for referenced libraries if using Csc.exe to compile individual files.

C# Project Management with Maven

Anyone had experience of managing C# based projects with Maven?
If yes , please tell me a few words about it , how weird would it be to create such a setup.
Thanks
Maven is language agnostic and it should be possible to use it with other languages than Java, including C#. For example, the Maven Compiler Plugin can be configured to use the csharp compiler. There is also a .NET Maven plugin and there was a maven-csharp on javaforge.com (seems dead).
But Java is getting most attention and man power and there is not much done with other languages. So, while using Maven with C# is in theory possible, I wouldn't expect much support and feedback from the community (i.e. in case of problem, you'll be alone). I don't know if using Maven for C# would thus be a good idea. I wouldn't recommend it actually (I may be wrong of course).
I work with a suite of C# and C++ components and applications that are dependency-managed via maven. The general rule of "If it can be done via command-line, it can be done in maven" holds, so we end up having a lot of .bat, .exe and powershell "glue" to get all the pieces playing together.
The biggest problem with using maven for a Microsoft stack is a complete lack of familiarity with the build/deployment/ALM cycle for ANY new developer. You can find many developers with MSBuild, TFSBuild, ANT, etc., experience, but it's a rare thing to find a C# or C++ dev who's worked with maven in a pure Microsoft shop. The rollout of maven for dependency management and build process is consequently extremely difficult, since you end up spending a LOT of time training developers (what's the difference between a snapshot and a release?), over-componentizing the product then scaling it back to get it right, etc.
I've also found that we've had to work around maven to do something resembling continuous integration and continuous delivery. About 70% of our technology stack is C# (the rest being C++), and we want to deploy most of that to QA servers every single night with the latest-and-greatest code by default. To balance the value of release builds vs. dev productivity via snapshots, we ended up constructing a build process where we create a release build of every component each night, followed by a snapshot build. This let the developers not have to worry about bumping POMs to consume snapshots in the morning. Overall, it's a royal pain, at least for someone coming from robust continuous integration, "build and deploy everything" environments.
Maven holds a lot of promise for dependency management and isolating breaking changes (particularly in interface components where the consumer and producer have to agree). Those problems have been solved other ways (svn externs, deployment builds, interface version management, etc.). But it is relatively nice to download any component, run "mvn compile", and see the code compile (assuming a basic level of build portability). For me, though, the overhead and the meta-conversations about getting the build right (as opposed to focusing on customer value) minimize the value of maven overall.
For .NET Core, you can use the dotnet-maven-plugin which drives the dotnet and nuget commands, as well as adds support for e.g. cleaning, releasing etc. in the "Maven way".
Here's an example plugin configuration:
<project>
[...]
<packaging>dotnet</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>org.eobjects.build</groupId>
<artifactId>dotnet-maven-plugin</artifactId>
<version>0.11</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
[...]
</project>
(Notice the packaging type set to dotnet).
This will then read from the project.json file and run dotnet and nuget commands according to the maven lifecycle phases such as clean, compile, test, install etc.
You might also check out NPanday (it is a project I am involved in). While it still needs some work to more closely align to Maven's best practices, it is the most complete and active alternative available now. One feature that is unique to it is the existence of a Visual Studio Add-in for generating the correct pom.xml from the IDE.
There is a NMaven project at codeplex but it doesn't seem to be active or popular. See also these questions:
maven for .NET (DroidIn.net's link to his tutorial looks promising)
Why is there no need for maven in
.NET
Is there a Maven Alternative or port
for the .NET world?
maven-compiler-plugin with plexus-compiler-csharp works just fine with the following configuration. Of course you'll have to point to an actual C# compiler on your machine with the "executable" parameter.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerId>csharp</compilerId>
<fork>true</fork>
<executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe</executable>
<outputFileName>myDLL</outputFileName>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-csharp</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
Check this out: http://interfaceable.blogspot.com/2019/01/how-to-mavenize-visual-studio-project.html
At the time i developed those scripts/solution i was unaware that such csharp support existed from Maven, but i do recommend using Maven for the build since it enables you to automate/orchestrate everything such as IIS + ActiveMQ + MongoDB bring-up on the pre-integration-test phase, and then we are able to run tests using vstest. Not to mention that you can integrate it with Jenkins and run your builds on a remote machine.
I personally recommend it, but bear in mind that you will be faced with some challenges sometimes.

Are there any emacs or vim editors with code completion plugins for C#?

It would be nice if it did both a list of methods to choose from and the list of potential input parameters. This was done for powershell and I was curious if there was any similar functionality implemented for emacs or vim?
Clarification:
A fellow developer I work with wants to use either vim or emacs for the low overhead without running visual studio. In essence he would like to be able to write tests, edit code in emacs or vim then just run NANT scripts to compile the code and run the tests. The only feature from Visual Studio he wants is code completion. The rest he can live without for 98-99 percent of the time.
You can use a vim editor emulator for Visual Studio.
http://www.viemu.com/
I haven't come across an emacs mode that would offer code completion suggestions based on "knowledge" of the API(s) that the user's environment is offering. To a lot of people this is an issue which prevents them from attempting to use Emacs or VIM when working with rich/large/unwieldy (delete as applicable) APIs.
However I am wondering how much of a problem this would present during day-to-day work. I've been using Emacs with C#-mode to crank out quite a lot of C# code. I also tend to run dabbrev-mode or pabbrev-mode, which tends to take care of the more common function and variable names I tend to use. To my eternal shame I have to admit that I tend to have a browser open on the MSDN website to look up the rest - those APIs that I don't use often enough to remember. Another potential helper that your colleague might want to look into is icicles, which may also be a step in the right direction. Neither of these libraries however will offer the full breadth of completion support that something the like Visual Studio IDE will offer. I'd see this as part of the trade-off when using a more efficient editor.
As an aside, if your colleague is working in a team and other members working on the same project are using Visual Studio, MSBuild might offer a better solution for building outside of VS than Nant as MSBuild reads the same solution and project files that VS uses (in fact a lot of the build work in VS2008 is handled by MSBuild). The syntax isn't too far away from Nant and with the community tasks added (which gives you NUnit integration etc) and it'll ensure that everybody is using very similar mechanisms to build the executables.
The furthest along completion I've seen for C# is at this blog, specifically at this post. (Blog link included for context and other Emacs posts.)
If you can live with dumb completion, you might be able to roll your own with tags and tag completion.
A previous stack on the same issue.
Your source code should be processed through the CEDET framework: http://cedet.sourceforge.net/
Then either use the example UIs bundled with cedet or else try any of these two:
- company-mode: http://nschum.de/src/emacs/company-mode
- completion-ui: http://www.dr-qubit.org/emacs.php
both supporting CEDET as a completion search backend.
apa!
for emacs and C# you can look at this tool : http://code.google.com/p/idebridge/
OmniSharp provides contextual intellisense for C# in vim.
Some of the suggestions in Eclipse Style Function Completions in Emacs for C, C++ and JAVA? may be relevant for emacs.
Not c# specific, but still.
I have found the http://code.google.com/p/csense this is an emacs c# intellisense/code sense. I found it from this blog post http://osdir.com/ml/emacs.sources/2007-11/msg00018.html, this may be close to the answer I was looking for.
After looking further it has not been updated since November 2007, looks stale to me.
For Vim, you can install insenvim. It support for the C# code completion.
After download the plugin you could install the installation file or install manually by following steps:
Copy the file cs_vis.vim into your $VIM\vimfiles\ftplugin directory.
Copy the file csft.dll into your $VIM_INTELLISENSE directory.
Copy CSVimHelper.dll,reg.bat to your $VIM_INTELLISENSE directory.
Run reg.bat to register the dlls. You need to set the directory gacutil.exe
in the path. You need the latest version of .NET SDK.

Categories