动态编译的项目丢失资源

时间:2016-09-09 12:23:37

标签: c# roslyn

我需要动态编译大项目的源代码,输出类型可以是Windows应用程序或类库。 代码很好地执行,它可以制作.dll或.exe文件,但问题是,当我试图制作.exe文件时 - 它正在丢失项目图标等资源。结果文件不包含汇编信息。

有什么方法可以解决这个问题? (预期结果应该相同,即在Visual Studio 2015中对项目文件进行手动构建功能)。 谢谢!

Started by user Erol Suleyman
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://bitbucket.xxx.xxx/scm/cha/jenkins-pipeline.git # timeout=10
Fetching upstream changes from https://bitbucket.xxx.xxx/scm/cha/jenkins-pipeline.git
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username esuleyman # timeout=10
 > git config --local credential.helper store --file=/tmp/git6615956696298607518.credentials # timeout=10
Setting http proxy: xxxxxxxx.xxxxxx.com:8080
 > git -c core.askpass=true fetch --tags --progress https://bitbucket.xxx.xxx/scm/cha/jenkins-pipeline.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 8f5a9f8f376a1a7ddd5dd23c533286cf511fba6f (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 8f5a9f8f376a1a7ddd5dd23c533286cf511fba6f
 > git rev-list 77448171a2b76eb268d7415e1b3c524f10219e22 # timeout=10
ERROR: /u01/appl/jenkins/workspace/SoapUI/test-git-pipeline@script/lab_4a/complete_list/test/Jenkinsfile not found
Finished: FAILURE

1 个答案:

答案 0 :(得分:2)

我们从未真正设计过工作区API,以包含您需要发出的所有信息;特别是当你打电话给Emit时,你可以传递EmitOptions,其中包括资源信息。但是我们没有公开这些信息,因为这个场景没有被广泛考虑。我们done some of the work in the past to enable this但最终从未合并过它。您可能希望考虑提交错误,以便我们在某处正式提出请求。

那你能做什么?我认为还有一些选择。 可能根本不考虑使用Roslyn,而是修改项目文件并使用MSBuild API构建它。不幸的是,我不知道你最终想要在这里实现什么(如果你提到它会有所帮助),但不仅仅是构建项目所涉及的编译器调用。更改引用也可能会改变其他内容。

当然,也可以自己更新MSBuildWorkspace以通过它。如果您要修改Roslyn代码,则会看到我们implement a series of interfaces named "ICscHostObject#" (where # is a number) and we get passed the information from MSBuild to that。看起来我们已经在命令行参数中存储了它,因此您可以将它传递给我们的命令行解析器,并以这种方式获取数据。