I am using VS2015, and MSBuild 14.
My solution has many projects, but three of them are old ASMX web sites. The ASMX website "projects" don't have their own project files, but are detailed in the XML of the solution file itself.
The solution builds fine inside Visual Studio.
However, when I try to build on the command line with MSBuild, I am getting an error message. Here is my MSBuild command:
C:\> msbuild MySolution.sln /t:MyAsmxProject
All the dependent projects (mostly c# class libraries) are built as I would expect them to be. Lots of output to the cmd window in which msbuild is running, until we get to the following action by msbuild:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /MyAsmxProject
-p MyAsmxProject\ -u -f -d -fixednames Precompiled\MyAsmxProject\
The whole thing bombs out here with the following error:
ASPNETCOMPILER : error ASPCONFIG: Could not load the assembly.
The property 'assembly' must be a valid assembly.
[C:\My\Long\Path\MySolution\MyAsmxProject.metaproj]
Now at first I didn't know what a "metaproj" file was, and was unable to find that file, but I did understand it to be an intervening project file created internally so that msbuild could operate on solution files. I discovered that I could see the metaproj file if I set the environment variable:
set MSBuildEmitSolution=1
And then re-ran the msbuild command. I now have metaproj files for both my solution and for my asmx project, which would appear to be the one referenced in the error message above.
These are both pretty dense msbuild files, but neither one of them have an XML node (element) named "assembly" and neither one of them have any XML nodes with the attribute or property "assembly" applied to them.
So I am unclear what this error is saying and how to fix it. And doubly unclear as to why it crops up with msbuild, but not with visual studio.
Any insights or suggestions most appreciated.
Although I don't fully understand why, I have found a solution.
Namely, if I run the command window in which I am doing the msbuild as an administrator, I don't get this error. This is an acceptable solution for me.
However.... it would still be great to understand more specifically what the error means, and why being an adminstrator makes the difference.
Related
I'm building an asp.net application using VScode, scaffolding areas using "aspnet-codegenerator" command always fail because of missing files.
I tried to uninstall the tool and reinstall it again, but still the same error
Firstly, please try to check if MvcControllerWithContext.cshtml file does exist under that folder mentioned in error.
Templates file path on my computer
C:\Users\user_name_here\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\verison_here(such as 3.1.4)\Templates\ControllerGenerator
Besides, if you indeed installed the dotnet-aspnet-codegenerator tool, but error still occurs, you can try this workaround:
copy Templates/ControllerGenerator and Templetes/ViewGenerator to the project folder
then rebuild the project and run your dotnet aspnet-codegenerator command to generate controller and view etc.
I have a web app in dot net along with other projects. when i open the .sln file and publish the web project, it does. But, when I try to publish the web proj using command line and .csproj, it gives an error. "Nothing to do. None of the projects specified contain packages to restore."
I got this after converting my csproj to vs2019 format and running dotnet test. The solution was to ensure i had the right test adapter and framework. My csproj files had both the old Microsoft.VisualStudio.QualityTools.UnitTestFramework reference and the new MSTest.TestAdapter + MSTest.TestFramework + Microsoft.NET.Test.Sdk.
I kept the new ones and my tests were run.
I had this problem in a batch file I use to build a UWP component for release. The build command is
%MSBUILD% CartoType\src\main\single_library\uwp\CartoType\CartoType.sln -p:Configuration=Release;Platform=x64
where %MSBUILD% is the full path to msbuild. I first added an msbuild command with the -t:restore option and got the message reported by the original poster ('Nothing to do. None of the projects specified contain packages to restore').
The solution was to add this command before the command given above:
%MSBUILD% CartoType\src\main\single_library\uwp\CartoType\CartoType.sln -p:RestorePackagesConfig=true -t:restore
We are attempting to install a clean build of the newest version of Kentico (12) on Azure, using Kudu, in DEBUG configuration. We traditionally accomplish this by setting SCM_BUILD_ARGS to -p:Configuration=Debug, and all is well. But for some reason in this newer version, the project fails to compile, and I see that this is the command being run:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\User\Documents\GitHub\Project\CMS\CMSApp.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="C:\local\Temp\8d6d315018f5ff9";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="C:\Users\User\Documents\GitHub\Project\.\\" -p:Configuration=Debug
Notice both Configuration=Release and Configuration=Debug. The compilation errors are things like Invalid expression term 'string' on the following line of code:
bool licenseOK = LicenseHelper.CheckLicenseLimitations(FeatureEnum.Ecommerce, out int skuCount, out int maxSKUCount);
This doesn't highlight at all in Visual Studio in Debug or Release mode. I am also able to reproduce locally (as shown in my paths above), and if I change the two configurations to both be the same (regardless of whether I choose Debug or Release), it compiles just fine.
What I know I can do is create my own custom deployment command script file as a work-around, but I guess I don't understand why the above MSBUILD command isn't working in the first place.
Any ideas as to why this would work great for all of my ASP.NET projects prior to this one? One thing I know is that Kentico recently included the Roslyn compiler, which I am unfortunately not that familiar with - could that be part of the issue?
UPDATE #1: It appears all of the compilation errors have to do with code that is only valid in C# 7.0. That could be a clue.
It all came down to the fact that the newer versions of Kentico had code that was only valid in C# 7, and required MSBuild 15 to compile. Here's how I was able to set up Kudu:
Add a file named .deployment in the root of my repo, containing only the contents below. This tells Kudu to use a custom deployment script.
Download the deploy.cmd file from my Azure App Service via FTP to the root of my repo, and update it per https://github.com/projectkudu/kudu/issues/2350#issuecomment-373817740 to use the MSBuild 15 path. Details below.
.deployment file contents
[config]
command = deploy.cmd
deploy.cmd updates
1 - Add -MSBuildPath "%MSBUILD_15_DIR%" to nuget call. Example:
nuget.exe restore "{your .sln file path}" -MSBuildPath "%MSBUILD_15_DIR%"
2 - Replace %MSBUILD_PATH% with %MSBUILD_15_DIR%\MSBuild.exe in both occurrences under step 2. Build to the temporary path
This was all that was needed in order to get the build to complete.
As Keith mentions, it was a compatibility issue with C# 7.0 that Kentico 12 uses. This SO thread mentions that you need to run MSBuild version 15 for C# 7.0 code. I ran a similar debug command for my local Kentico 12 project using MSBuild 15, and it succeeded.
I posted this on the Kobold2d forums but haven't received any replies yet. I'm hoping the larger audience here at SO can help.
I'm trying to get our Kobold2d project working with our Hudson CI server. I'd like to have a script that executes the proper command line build instructions using xcodebuild, but I'm running into a problem with any Kobold2d project.
As a test I created a Orthogonal-Tilemap template project and built/ran it in the xcode 4.4.1 gui successfully. Building the projects individually from the command line the Kobold2D-Libraries.xcodeproj reports a successful build (though I have no idea where any products are stored), but the tilemap project fails with the message:
ld: file not found: <path>/Kobold2D/Kobold2D-2.0.3/BuildTest/build/Release-iphoneos/libkobold2d-ios.a
The only information I can find on this message talks about errors from building in the xcode gui, which is not the problem.
I also tried having xcodebuild build the workspace file but that failed with multiple dependency errors.
Has anyone found a way to successfully build Kobold2d projects from the command line?
Thanks!
Actually I use Hudson to automate Kobold2D builds. Here's the build script for Hudson.
I can see from your path that you changed Xcode's default build locations (Advanced, next to Derived Data in Preferences -> Locations). There's one setting (legacy) that doesn't work at all with Kobold2D, and should actually open a browser window explaining the issue should you have used that setting.
I think your setting is "relative to project" or something similar. Try changing the build location to Xcode default (Unique) and try again. You can use a custom location for derived data if you want to.
In any case, if the output location path of build products ends up being somewhere in the app project folder (in this case: BuildTest) then ld won't be able to find dependencies because they're not all in the same folder. If you do require this you could add a pre-link step that copies the .a files to the correct location. But it's best to avoid this because it'll be prone to breaking.
My script includes
xcodebuild -workspace Bulge.xcworkspace -scheme Bulge-iOS -sdk ${sdk} archive || die "Archive failed"
I have a solution which contains many class libraries and an ASP .NET website which references those assemblies.
When I build the solution from within the IDE, all assemblies referenced by the website end up in the bin directory. Great!
When I use MsBuild from the command line, all the referenced assemblies are not copied to the bin directory. Why?
My command line is simply:
msbuild.exe d:\myproject\mysolution.sln
I have found various references to this problem scattered around the Net - and I've just come across it myself. Apparently MSBuild on the command line isn't as good at tracing chains of dependencies as the IDE is.
So as I understand it, if A depends on B which depends on C, The command line may not realize that A depends on C.
The only solution I've found is to ensure that you manually set the project dependencies so that the ASP project references everything it depends on - don't expect it to be able to figure them all out on the command line. This has worked for me, although I only have 5 projects so it's not a bind to get going.
I hope this helps.
The issue I was facing was I have a project that is dependent on a library project. In order to build I was following these steps:
msbuild.exe myproject.vbproj /T:Rebuild
msbuild.exe myproject.vbproj /T:Package
That of course meant I was missing my library's dll files in bin and most importantly in the package zip file. I found this works perfectly:
msbuild.exe myproject.vbproj /T:Rebuild;Package
I have no idea why this work or why it didn't in the first place. But hope that helps.
Which msbuild are you referencing? Is it the right one?
I generally call like this (from a batch file):
%WINDIR%\Microsoft.NET\Framework\v3.5\msbuild.exe deploy.proj /v:n
In this example, deploy.proj is just a regular msbuild file that does some other stuff before and after calling msbuild on the .sln file.
I think this problem only occurs when your bin directory is not the framework's default for a solution.
I understand that msbuild uses each project set up to build it. If this is so, please go to each projects properties page and check the post build event command line arguments.
You could always use a copy task in MSBuild to pull your assemblies into the proper directory. I asked a question not to long ago and ended up answering it myself. It shows how you can setup your Copy task to grab output from another project and pull it into your target project:
MSBuild copy output from another project into the output of the current project
I haven't been using msbuild for ASP.NET, but aspnet_compiler. Though...I don't remember why. Sorry.
%windir%\Microsoft.Net\framework\v2.0.50727\aspnet_compiler -v \%~n1 -f -p .\%1 .\Website
You could make use of the Post-Build steps in project properties to copy the output for the project to a particular location.
This copies to an Assemblies directory in the same directory as the Sln file. I have this in the post-build step of all my projects.
md "$(SolutionDir)Assemblies"
del "$(SolutionDir)Assemblies\$(TargetFileName)"
copy "$(TargetPath)" "$(SolutionDir)Assemblies" /y
Known problem ffor MSBuild 3.5 and msbuild 4.5. I am using Msbuild 4 found at
c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe <yourSolutionFile>.sln
It seems to solve the problem.
If I recall, MSBuild dosen't copy the referenced assemblies.
I've posted a "solution" a while ago:
http://www.brunofigueiredo.com/post/Issue-Tracker-part-IV-The-Build-Enviroment-using-MSBuild-(or-NAnt).aspx
Hope it helps.