次の方法で共有


Error : The OutputPath property is not set for project 'xxxxx.dbproj'.

I had an interesting case the other day and I thought I’d share how we managed to get around the problem.

This post will not discuss why this happens or if this is the correct behavior. It will just show a way to build your project.

 

So, the scenario is as follows.

In Visual Studio 2008 you create a new Database Project, for example, for SQL Server 2005 (Database Project -> Microsoft SQL Server -> SQL Server 2005).

For this example, we call it DbProj.

Then save everything (Ctrl + Shift + S) and then close the project and Visual Studio 2008.

 

Open the solution in Visual Studio 2010.

This will bring up the Conversion wizard. Just hit Finish to convert the project and the close it in the Conversion Complete dialog.

 

Now open the Configuration Manager, for example, by right clicking the solution in Solution Explorer, then select Configuration Manager.

In the “Active solution configuration” drop down, select <New…>.

Give it a name, for example MyConfig, and leave the "Create new project configurations" checkbox checked.

 

Click Ok - Click Close.

The MyConfig should now be selected.

Build project (F6).

And you may get this message:

 

------ Build started: Project: DbProjRepro, Configuration: MyConfig Any CPU ------

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9): Error : The OutputPath property is not set for project 'DbProjRepro.dbproj'.

Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.

Configuration='MyConfig' Platform=''. 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.

Done executing task "Error" -- FAILED.

Done building target "_CheckForInvalidConfigurationAndPlatform" in project "DbProjRepro.dbproj" -- FAILED.

Done building project "DbProjRepro.dbproj" -- FAILED.

Build FAILED.

========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

 

Now, the problem seems to be that the new config (MyConfig) and the properties for it (OutputPath in this case) is not saved to the .dbproj file.

 

One way to get around this and to let you build the project is to manually add the PropertyGroup in the .dbproj file. This can be done like so:

 

Right click the project.

Select "Unload project", the project should now have (unavailable) after it.

Right click and select Edit <projectname>.dbproj

Add the following in the Project node.

Place it directly under: <Project DefaultTargets="Build" xmlns="https://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> for example.

 

  <PropertyGroup Condition=" '$(Configuration)' == 'MyConfig' ">

    <OutputPath>.\sql\MyConfig\</OutputPath>

  </PropertyGroup>

 

Replace MyConfig with whatever your config is called.

Save the file and close it.

Right click the project and select "Reload Project"

Build with F6. This should now work.