I have a few classes with the same namespace, and I want to put all of them in a dll file, and use it in other places.
I read the guide on Microsoft's website:
http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
They suggested this:
To build the file [myDllName].DLL, compile the two files [myClass1].cs and
[myClass2].cs using the following command line:
csc /target:library /out:[myDllName].DLL [myClass1].cs [myClass2].cs
I wrote it in a cmd window and got an error that there is no such command as csc.
Plus, how it will find my files without a path?
So what is the right way of doing it? Where should I write it?
I saw some posts here with Library classes.. but not sure how it can help me.
My classes are in a different solution, and I just want to use it as an external dll, and not within the same solution.
In this case, Microsoft's guide seems perfect, if it will work.
If you use the Visual Studio Command Prompt window, all the necessary environment variables are set for you. In Windows 7, you can access that window from the Start menu by opening the Microsoft Visual Studio Version\Visual Studio Tools folder. In Windows 8, the Visual Studio Command Prompt is called the Developer Command Prompt for VS2012, and you can find it by searching from the Start screen.
source
You can run the vsvars batch file from a command prompt and it will set paths for you, for that instance of cmd.exe
Mine is here:
>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
Why don't you just create a separate 'Class Library' project in your solution in Visual Studio?
You can than easily add it as a project reference to all other projects that need it.
You can create Solution Folders in VS to logically group projects.
Make sure csc.exe is in your PATH environment variable.
You should have a vsvars32.bat that was installed with Visual Studio. You can run that to automatically add it to the path, or dig down in regedit to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
Look through the subtrees in there for your framework version, and for an InstallPath key. That should tell you what directory to look in.
You can then use that, and:
WHERE /r "the_directory_you_found" csc.exe
to find the path. Add that to your system environment variables, and you should be able to find it.
As for the path of the class files, either run the command from the directory they're in, or specify the path when specifying the class files.
If you have Visual Studio installed, you could try creating a 'Class Library' project; Or you can run csc.exe by Launching "Visual Studio Command Prompt".
If you don't have Visual Studio installed but have .net framework installed. You can run csc.exe from the framework installation directory.
Installation directory path for .net Framework 4.0 :
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
Related
I wrote a simple C# file. When I compile it using command prompt, I get an error
'csc' is not recognized as an internal or external command, operable program or batch file.
Do I need to set an environment variable?
When you install Visual Studio it comes with it a batch file that sets up the environment for you and opens a cmd window. It's called Developer Command Prompt for VS201x (where x is the Visual Studio version you have). It is located in the Visual Studio Tools menu, usually at:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Visual Studio 201x\Visual Studio Tools
This is the result:
EDIT:
If you don't have Visual Studio installed you can still access the C# compiler shipped with the .NET Framework in Windows 8. You will find it in:
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Otherwise you can install it manually. Here is the link
What you need to do after is just adding it to your environment variable path
Hope it helps.
I have cloned a project to my computer using TFS, when I build the project I get this error :
Error 6 Task could not find "LC.exe" using the SdkToolsPath "" or the
registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v8.1A\WinSDK-NetFx40Tools-x86". Make sure the
SdkToolsPath is set and the tool exists in the correct processor
specific location under the SdkToolsPath and that the Microsoft
Windows SDK is installed
I have searched the web but couldn't find a solution. I use VS 2013 and .NET 4.
How can I fix this? Thanks.
If you're using MSBuild.exe to build projects from the command line, you can pass TargetFrameworkSDKToolsDirectory as a parameter to avoid having to edit your .csproj files.
For example:
MSBuild.exe mysolution.sln /t:build /p:TargetFrameworkSDKToolsDirectory="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools"
It turns out you can specify the path to the SDK directly in the .csproj file:
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools</TargetFrameworkSDKToolsDirectory>
and the build found lc.exe that way.
So do a dir /s for lc.exe and use that path.
I previously expected to set this using <SdkToolsPath>, but that didn't work. In Microsoft.Common.targets, SdkToolsPath gets set from TargetFrameworkSDKToolsDirectory, so I tried that and it worked. (It would be nice if the variable name corresponded 1 to 1, but they don't.)
This is on Visual Studio 2015, and msbuild being called from ant.
I was having the same problem and resolved it by re-installing the Visual Studio.
http://msdn.microsoft.com/en-us/library/ha0k3c9f(v=vs.110).aspx
The License Compiler reads text files that contain licensing
information and produces a binary file that can be embedded in a
common language runtime executable as a resource. A .licx text file is
automatically generated or updated by the Windows Forms Designer
whenever a licensed control is added to the form. As part of
compilation, the project system will transform the .licx text file
into a .licenses binary resource that provides support for .NET
control licensing. The binary resource will then be embedded in the
project output. Cross compilation between 32-bit and 64-bit is not
supported when you use the License Compiler when building your
project. This is because the License Compiler has to load assemblies,
and loading 64-bit assemblies from a 32-bit application is not
allowed, and vice versa. In this case, use the License Compiler from
the command line to compile the license manually, and specify the
corresponding architecture. This tool is automatically installed with
Visual Studio. To run the tool, use the Developer Command Prompt (or
the Visual Studio Command Prompt in Windows 7). For more information,
see Visual Studio Command Prompt.
I want to write to visual studio output window in my add in. I found a code from
How do I write to the Visual Studio Output Window in My Custom Tool?
But I can't add a reference to IVsOutputWindow.
There is no any namespace like Microsoft.VisualStudio.Shell.Interop
and also no dll. How should I fix this problem
Thank you.
It sounds like you're having trouble locating the IVsOutputWindow interface. If so here is the information on that type
Namespace: Microsoft.VisualStudio.Shell.Interop
DLL: Microsoft.VisualStudio.Shell.Interop
If the SDK is install on your machine the DLL will be located in the following directory
C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.dll
The top 2 directories may change though based on the operating system and version of the SDK you are using. If this doesn't work please let me know the SDK version you are using and I'll try and point you to the correct path.
I found that I had to actually download and install the Visual Studio SDK - it's a separate download that's not included with Visual Studio itself. Once installed, I restarted Visual Studio, and the necessary assemblies were listed when I went to add references to my project.
I want to create a very simple .exe that will install a driver. I have an .inf (and all it's DLL files). The driver is for a usb device.
The end goal is to find a simple solution to install a driver with my application installer. The installer is generated using Visual Studio 2008 setup and deployment project. I believe that having a separate exe that does the driver install can be called by my setup and deployment project.
I am a newbie at this so i am looking for a step by step tutorial or something that i can really understand.
Please help :(
EDIT:
The following command line installs the driver just fine. How can I transfer this into a EXE or DLL, which can be launched by custom actions in Visual Studio
rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 .\<file>.inf
Have you checked How do I deploy a .inf based driver?
The Visual Studio Setup & Deployment project is fairly limited in functionality: probably the easiest way to create an installer for your driver is to use WiX and DIFx - you just need to add a difx:Driver tag to your source file and use the WixDifxAppExtension extension when running candle/light. An example from the project I work on can be seen at http://www.bluestop.org/viewvc/repos/sctpDrv/trunk/wix/ - the candle/light commands are in Makefile.wix and module-common.wxs contains the DIFx code.
The output of WiX is an MSI file. If you want a .exe I'd recommend using dotNetInstaller, which can bootstrap any prerequisites before running your MSI.
Doesn't the .inf file itself install the driver?
If for some reason you are using a tool that (unlike say explorer) isn't smart enough to know that is what inf's are for, perhaps you could write a little program that tells windows explorer to run the inf file.
I believe that the 'start' command will run an associated file at the command line.
So a one line script aught to do (example run.cmd file):
start myWordDoc.doc
That command will open up Word and Load that document.
It 'should' do the same for INF files, let me know if it does.
I'm using Visual Studio 2008 to write an installation, and I'm a completely new to installations. I've created an installation and successfully written some custom actions using a C# assembly. One action sets a RunOnce registry value, and now I need to prompt the user to reboot when the installation finishes, but I have no idea how. I've read the Installer class documentation, but I can't find any mention of rebooting.
I'm assuming I need to somehow get down to being able to call MsiSetProperty and set a REBOOT property, but I don't know how to do that from my .NET installer project.
Thanks. I ended up using a post-build event to run a batch file with the following command. The hard part was tracking down WiRunSQL.vbs, which was in the "Windows SDK Components for Windows Installer Developers" download.
cscript "C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\SysMgmt\MSI\scripts\WiRunSQl.vbs" my.msi "INSERT INTO `Property`(`Property`, `Value`) VALUES ('REBOOT', 'F')"
If you are implementing your installer using WiX, you need to add this:
<ScheduleReboot After="InstallFinalize"/>
If you're using the cut-down "Installer" project in Visual Studio, I'm not sure... But this link here suggests a CScript command that seems to show how to inject an MSI property into the installer project, much as you want to do.
Just set the property in the MSI initally, rather than trying to update it at runtime.
Visual Studio 2008 ships with WiX anyway, see Visual Studio ships the WiX toolset for more details. That said, I'm not a Visual Studio 2008 user, so I don't know if that's in addition, or in replacement to the previous Visual Studio setup projects.