2

I have a batch file that builds an ASP.NET web application project, but it's not taking in the Entity Framework resource files in the Core Compile process.

The build script is:

set proj_name=MyProject
set proj_path=C:\...\path-to-project\
set pkg_name=MyProject.zip
set build_config=Release
set platform=AnyCPU
set msbuild=%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe

%msbuild% "%proj_path%%proj_name%.csproj"  /t:package /p:OutPath="%proj_path%obj" /p:OutputPath="%proj_path%bin" /p:Configuration=%build_config% /p:Platform=%platform%

While the script completes without errors, but the web app crash with Unable to load the specified metadata resource error.

But if I do a Visual Studio Publish, everything works fine. So that points me to look into my build output.

After carefully comparing the Visual Studio Publish output and my build script output, I found in the CoreCompile section, the csdi, msl and ssdl files are missing from my build script output. But the files are there on the file system and part of the Solution and Project. So I'm not sure why they are not included during the build. Below, is part of the build output:

Visual Studio Publish output:

/debug:pdbonly /optimize+ /out:obj\Release\Dnr.MotorPool.dll 
/resource:obj\Release\edmxResourcesToEmbed\DataAccess\MyDataModel.csdl,DataAccess.MyDataModel.csdl 
/resource:obj\Release\edmxResourcesToEmbed\DataAccess\MyDataModel.msl,DataAccess.MyDataModel.msl 
/resource:obj\Release\edmxResourcesToEmbed\DataAccess\MyDataModel.ssdl,DataAccess.MyDataModel.ssdl 
/target:library 
/utf8output all the cs files...

My build script output:

/debug:pdbonly /optimize+ /out:obj\Release\Dnr.MotorPool.dll 
/target:library 
/utf8output all the cs files...

So clearly, there are 3 missing files. How do I modify my build script then?

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137
  • try `/t:ResolveReferences;package` – KMoraz Dec 07 '12 at 23:43
  • @KMoraz, I changed the build script to `%msbuild% "%proj_path%%proj_name%.csproj" /t:ResolveReferences;package /p:OutPath="%proj_path%obj" /p:OutputPath="%proj_path%bin" /p:Configuration=%build_config% /p:Platform=%platform%` but the missing files are still missing. – Ray Cheng Dec 10 '12 at 18:52
  • @KMoraz, I got it working by using your suggestion (`/t:rebuild:package`) in another post. http://stackoverflow.com/questions/9633408/msbuild-package-via-command-line-not-including-all-my-assemblies – Ray Cheng Dec 10 '12 at 19:09

1 Answers1

3
%msbuild% "%proj_path%%proj_name%.csproj" /T:Rebuild;Package
KMoraz
  • 14,004
  • 3
  • 49
  • 82