简体   繁体   中英

How to get the source code from a last successful build

I was wondering if there was a way that I could snag the source code from the last successful build of a C# project in visual studio. The last build works just fine when I run it, but the current code doesn't work at all. Any way to do this?

If you are not using any central code repository (VSS, SVN etc) then you can see this link for more information on how to decomile a dll. http://social.msdn.microsoft.com/Forums/vstudio/en-US/05b3cf5d-ead3-4274-88f5-6e8cbda8e8d8/decompiling-a-dll-file-to-view-source-code?forum=msbuild

You can use a Reflection tool. Some options are:

http://ilspy.net/

http://www.jetbrains.com/decompiler/

在工作的dll(例如http://www.ilspy.net/)上使用反编译器,它可能不完全相同,但应足够接近以提供深入的了解

Every time you build your solution, the source file in your "Visual Studio / Projects / Your project / Your project" folder will be created (or overwritten) with a .cs extension. If you want to get the code as a string, you could simply run your app and use a StremReader object to do the work.

//...
StreamReader sr = new StreamReader(/*the source path*/);
txtSourceCode.Text = sr.ReadToEnd();
sr.Close();
sr.Dispose();
//...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM