VSCode c# add reference to custom assembly

前端 未结 3 2034
长情又很酷
长情又很酷 2021-01-11 15:04

in Visual Studio Code I simply want to add a reference to an custom c# assembly like

\"../libs/mylib.dll\"

how can I add this

3条回答
  •  情话喂你
    2021-01-11 16:01

    I finally found a way to reference any .net assembly within visual studio code.

    First to note: I only need the vscode for the intellisense. I will not compile the assembly in vscode /.netcore. When I'm done with coding, I will use commandline-tools to generate my assembly.

    And this is my solution:

    1. Create an regular .net class library with Visual studio (not code) This will create an myproject.csproj-file (wich can be read by vscode). Or use my test.csproj-file at the bottom of the post.

    2. create an folder for the referenced assemblies. I've just created an libs-directory inside the top-directory.

    3. close vs and open the folder with vscode.

    4. modify the *.csproj-file as followed:

    note: we've created the project in debug-mode, so we can remove the release-property-group:

    4.2. remove the Release-PropertyGroup (you don't have to, but you don't need it)

    
        pdbonly
        true
        bin\Release\
        TRACE
        prompt
        4
      
    

    4.3. Modify the bin-output-path to the libs-directory

    from

    bin\Debug\
    

    to

    libs
    

    4.4. put your referencing .net assembly (external or custom) in the libs-directory and references them like:

    ...
    
      
        
          False
          log4net.dll
        
        ...
      
    ...
    

    this is the complete *.csproj file with reference to an log4net.dll.

    
    
      
      
        Debug
        AnyCPU
        {75278D05-4850-4282-8AB4-3643A9E799FF}
        Library
        Properties
        Test
        Test
        v4.6
        512
      
      
        true
        full
        false
        libs
        DEBUG;TRACE
        prompt
        4
      
      
        
          False
          log4net.dll
        
        
        
        
        
        
        
        
        
      
      
        
      
      
      
      
      
    
    

提交回复
热议问题