简体   繁体   中英

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:

The OutputPath property is not set for project 'CT_NombreProyecto1.Services.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='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

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.

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?

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:

  1. Create a condition in each project on template like this

    Platform Condition=" '$(Platform)' == '' Or '$(Platform)' == 'BPC' ">AnyCPU

Visual Studio creates that condition tag with just blank option

  1. Delete Platform environment variable

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