草庐IT

c# - 从 VS 运行的 Azure 项目构建包,从命令行失败,错误 MSB4096

coder 2024-05-30 原文

我有一个 Windows Azure 云服务项目的解决方案,可以从 VS 和命令行编译得很好。

如果我尝试制作一个包,它在 VS 中工作正常,但在命令行中失败。

这是我在 Powershell 中的命令行:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\project.sln --% 
/p:Configuration="QA" /p:TargetProfile="CloudQA" /p:Platform="Any CPU" /target:Publish
/nr:false

我有这个错误:

"C:\CI\project\project.sln" (Publish target) (1) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj.metaproj" (Publish target) (11) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj" (Publish target) (12) ->
(PrepareRoleItems target) ->
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets(13
02,5): error MSB4096: The item "C:\CI\project\project.WebAPI\project.WebAPI.csproj" in item list "Projec
tReferenceWithConfiguration" does not define a value for metadata "Name".  In order to use this metadata, either qualif
y it by specifying %(ProjectReferenceWithConfiguration.Name), or ensure that all items in this list define a value for
this metadata. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]

编辑 一些有趣的事情: 这是我的 csdef 文件

<WorkerRole name="ProjectWorker" vmsize="ExtraSmall">
  <Imports>
    <Import moduleName="Diagnostics" />
  </Imports>
  <Endpoints>
    <InternalEndpoint name="InternalEndpoint1" protocol="http" />
  </Endpoints>
  <ConfigurationSettings>
  </ConfigurationSettings>
</WorkerRole>
<WebRole name="Project.Web" vmsize="ExtraSmall">
  <Sites>
    <Site name="Web">
      <Bindings>
        <Binding name="http" endpointName="http" />
      </Bindings>
    </Site>
    <Site name="Api" physicalDirectory="..\..\..\Project.WebAPI">
      <Bindings>
        <Binding name="http" endpointName="http81" />
      </Bindings>
    </Site>
  </Sites>
  <Endpoints>
    <InputEndpoint name="http" protocol="http" port="80" />
    <InputEndpoint name="http81" protocol="http" port="81" />
  </Endpoints>
  <Imports>
    <Import moduleName="Diagnostics" />
  </Imports>
</WebRole>

如您所见,我在一个 WebRole 上有两个网站。

现在,让我们看一下 ccproj 文件:

<ItemGroup>
  <ProjectReference Include="..\Project.Web\Project.Web.csproj">
    <Name>Project.Web</Name>
    <Project>{5d000123-0000-4b6e-b5fa-72525afca7f5}</Project>
    <Private>True</Private>
    <RoleType>Web</RoleType>
    <RoleName>Project.Web</RoleName>
    <UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
  </ProjectReference>
  <ProjectReference Include="..\ProjectWorker\ProjectWorker.csproj">
    <Name>ProjectWorker</Name>
    <Project>{22e99999-1000-4559-8507-a948b7e3d1b0}</Project>
    <Private>True</Private>
    <RoleType>Worker</RoleType>
    <RoleName>ProjectWorker</RoleName>
    <UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
  </ProjectReference>
</ItemGroup>

ccproj 中只引用了两个项目,而不是 3 个。

云项目在sln中有3个依赖。

如果我像这样在 ccproj 中手动引用:

<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
  <Name>Project.Web</Name>
  <Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
  <Private>True</Private>
  <RoleType>Web</RoleType>
  <RoleName>Project.WebAPI</RoleName>
  <UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>

我有这个错误:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
\Microsoft.WindowsAzure.targets(987,5): error : CloudServices25 : Multiple directories are 
specified for role Project.Web. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]

现在,如果我像这样更新引用:

<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
  <Name>Project.WebAPI</Name>
  <Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
  <Private>True</Private>
  <RoleType>Web</RoleType>
  <RoleName>Project.Web</RoleName>
  <UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>

我有这个错误:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
\Microsoft.WindowsAzure.targets(987,5): error : CloudServices26 : Cannot find role 
named 'Project.WebAPI' in service description file 
C:\CI\project\WindowsAzure\bin\UAT\ServiceDefinition.csdef.     
[C:\CI\project\WindowsAzure\WindowsAzure.ccproj]

最佳答案

我找到了这个链接:Visual Studio 2010 Beta 2 myTODO Error message这个对我有用。来自该链接的有值(value)的信息:

It seems like maybe Azure does not like it if you specify anything besides an Azure Role project as a dependency on the service project. I made it so MyWebRole.csproj was dependent on xxx.csproj, instead of MyService.ccproj being dependent on xxx.csproj, and it worked.

关于c# - 从 VS 运行的 Azure 项目构建包,从命令行失败,错误 MSB4096,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17048171/

有关c# - 从 VS 运行的 Azure 项目构建包,从命令行失败,错误 MSB4096的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby-on-rails - Railstutorial : db:populate vs. 工厂女孩 - 2

    在railstutorial中,作者为什么选择使用这个(代码list10.25):http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-usersnamespace:dbdodesc"Filldatabasewithsampledata"task:populate=>:environmentdoRake::Task['db:reset'].invokeUser.create!(:name=>"ExampleUser",:email=>"example@railstutorial.org",:passwo

  3. ruby - 在 Ruby 中编写命令行实用程序 - 2

    我想用ruby​​编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序

  4. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

  5. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  6. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  7. ruby - Sinatra:运行 rspec 测试时记录噪音 - 2

    Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/

  8. ruby-on-rails - 无法让 rspec、spork 和调试器正常运行 - 2

    GivenIamadumbprogrammerandIamusingrspecandIamusingsporkandIwanttodebug...mmm...let'ssaaay,aspecforPhone.那么,我应该把“require'ruby-debug'”行放在哪里,以便在phone_spec.rb的特定点停止处理?(我所要求的只是一个大而粗的箭头,即使是一个有挑战性的程序员也能看到:-3)我已经尝试了很多位置,除非我没有正确测试它们,否则会发生一些奇怪的事情:在spec_helper.rb中的以下位置:require'rubygems'require'spork'

  9. c# - 如何在 ruby​​ 中调用 C# dll? - 2

    如何在ruby​​中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL

  10. C# 到 Ruby sha1 base64 编码 - 2

    我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha

随机推荐