How to include another project Console Application exe in an Asp.Net website?

前端 未结 3 2032
谎友^
谎友^ 2021-01-13 01:43

I\'ve got two projects: a .Net 4.0 Console Application and an Asp.Net 4.0 Website (they are in the same solution). Now I\'d like to include

相关标签:
3条回答
  • 2021-01-13 02:28

    The exe option is available if you, use the browse tab instead.

    0 讨论(0)
  • 2021-01-13 02:30

    Have you tried just adding it as a "Project Reference" to the Website project? Right click on the website project, select "Add Reference..." and switch to the "Projects" tab.

    A quick test here showed that by doing that the output of the console app project (the .exe) was copied to the /bin folder of the website when I built the solution.

    You should then be able to use your standard deployment mechanisms to ensure that this is copied to the server at the same time as the other libraries.


    Apologies, you're right, this doesn't work with a WebSite project, only with a Web Applciation.

    In this case, you'll have to use a "Post Build" event on your console app to copy it to the website's folder.

    Right click on the console app project in the Solution Explorer and select "Properties" or when you have a file from the project open use the "Project" menu.

    Then on the "Build Events" tab, update the "Post-build event command line" to something like:

    xcopy "$(TargetDir)$(TargetFileName)" "c:\users\[UserName]\Documents\Visual Studio 2010\Websites\[ProjectName]\bin\" /D /S /I /Y
    

    If you want to include the PDB and config files as well then something like the following would be better:

    xcopy "$(TargetDir)$(TargetName).*" "c:\users\[UserName]\Documents\Visual Studio 2010\Websites\[ProjectName]\bin\" /D /S /I /Y
    
    0 讨论(0)
  • 2021-01-13 02:31

    On the project you are trying to reference, make sure you change the output type to class Library. This should fix it.

    0 讨论(0)
提交回复
热议问题