Question

I'm building a tool that build .net projects with MSBuild command, and after this run the aspnet_compiler to precompile website and publish it programmatically. The problem is that some open source projects that I download give errors in some files. After this I search the differences between my approach of Visual studio and realize that this files in Visual Studio are Ignored. Also realize that visual studio first copy all files needed from the source folder of project to another folder, namely "obj\Debug\AspnetCompileMerge\Source". In this folder are only the files used in project and mentioned in the project file "web.csproj", and files that gave me error don't are copied.

So my question is, someone knows a way to do the step of copy only used files mentioned in .csproj? I think this will resolve my problem. In projects well configured the app works perfectly.

Was it helpful?

Solution

I found the solution. After building the solution with msbuild, just run msbuild again, but this time with some parameters that I found in web and here, Publish a Web Application from the Command Line to copy files mentioned in csproj to a destination folder. In these step are needed to copy also all dll files in bin folder because of some dependencies, for last run aspnet_compiler.

Above are a simple example of commands.

>msbuild.exe D:\proj\solution.sln

>msbuild.exe "D:\proj\webproj\proj.csproj" /t:_CopyWebApplication /p:OutDir="D:\proj\tmpFolder" /p:WebProjectOutputDir="D:\proj\tmpFolder"

>xcopy "D:\proj\webproj\bin" "D:\proj\tmpFolder\bin" /I /S /Y

>aspnet_compiler.exe -v / -p "D:\proj\tmpFolder" -d "D:\publishFolder"

I hope this can help someone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top