简体   繁体   English

Visual Studio模板上的项目参考

[英]Project Reference on Visual Studio Template

i am trying to create a Visual Studio C# template with multiple projects that reference each others, the problem is that once the template project is created, it can't find the namespaces from other projects, even if the references exist in the References dropdown, if i build the solution it shows this error: 我正在尝试创建一个包含多个相互引用的项目的Visual Studio C#模板,问题是,一旦创建了模板项目,就无法从其他项目中找到名称空间,即使引用存在于“引用”下拉列表中,如果我建立解决方案,它将显示此错误:

The OutputPath property is not set for project 'CT_NombreProyecto1.Services.csproj'. 未为项目“ CT_NombreProyecto1.Services.csproj”设置OutputPath属性。 Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. 请检查以确保为该项目指定了配置和平台的有效组合。 Configuration='Debug' Platform='BPC'. 配置=“调试”平台=“ BPC”。 This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. 如果某个其他项目试图遵循该项目的项目间引用,此项目已被卸载或未包含在解决方案中,并且引用项目未使用相同或等效项构建,则也可能会出现此错误。配置或平台。 CT_NombreProyecto1 CT_NombreProyecto1

The reference to other project is added this way: 通过以下方式添加对其他项目的引用:

<ProjectReference Include="..\$ext_safeprojectname$.Models\$ext_safeprojectname$.Models.csproj">
  <Project>{E9A103FE-307F-465D-BFD3-8E9D1C37F777}</Project>
  <Name>$ext_safeprojectname$.Models</Name>
</ProjectReference>

Where $ext_safeprojectname$ is a tag that inherits from root vstemplate file using CopyParameters on Project tags. 其中$ ext_safeprojectname $是使用Project标记上的CopyParameters从根vstemplate文件继承的标记。

I guess the error is happening cause it's trying to find and assembly DLL for the other project in the same solution, but how it is supposed to be solved if the solution can not build? 我猜该错误正在发生,原因是它试图在同一解决方案中为其他项目查找并组装DLL,但是如果解决方案无法构建,应该如何解决?

Any ideas?, Thanks 有什么想法吗,谢谢

I found the solution, the reason of the OutputPath error is a Windows environment variable called Platform, there are two workarounds creating vstemplates: 我找到了解决方案,OutputPath错误的原因是一个名为Platform的Windows环境变量,创建vstemplates有两种解决方法:

  1. Create a condition in each project on template like this 像这样在模板上的每个项目中创建条件

    Platform Condition=" '$(Platform)' == '' Or '$(Platform)' == 'BPC' ">AnyCPU Platform Condition =“'$(平台)'==''或'$(平台)'=='BPC'”> AnyCPU

Visual Studio creates that condition tag with just blank option Visual Studio仅使用空白选项创建该条件标签

  1. Delete Platform environment variable 删除平台环境变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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