Getting an error during the deploying webapplication "Could not open Source file: Could not find a part of the path" - asp.net-mvc

I got an error during the deploying my web-application.
The title of error is Could not open Source file: Could not find a part of the path
'Could not open Source file: Could not find a part of the path
'E:\ARCHIVES\Projects\Main\Jahan.Handicraft\Jahan.Handicraft.Web.Mvc.UmbracoCms.App\obj\Release\AspnetCompileMerge\TempBuildDir\App_Plugins\UmbracoForms\Data\Web.config;\App_Plugins\UmbracoForms\Data\Web.config'.'.
I've used Umbraco 7.4.3 und ASP.NET MVC in my project.
I'd like deploy it on localhost.
How can I solve this problem?

This is a failed attempt at transforming connection strings in sublevel configurations files.
To disable this transformation, edit the publish profile under Properties\PublishProfiles and set the value of the AutoParameterizationWebConfigConnectionStrings element to false. Add the element if missing.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
...
Other settings
...
-->
<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
</PropertyGroup>
</Project>
I got it from this blog (which is not mine): http://blog.aabech.no/archive/web-deploy-says-could-not-open-source-file-some-webconfig-when-you-publish-an-umbraco-site/

Post installation
You should note that the Umbraco nuget package adds a build step to always include the Umbraco folders when you deploy using Web One-Click Publish with Visual Studio.
You can see these folders in packages/UmbracoCms x.y.z/build/UmbracoCms.targets
Should you need to exclude any of these folders or content, you can add a target to your .pubxml files in the properties/Publish folder. For instance if you need to exclude json data a plugin generates during production.
<Target Name="StopUmbracoFromPublishingAppPlugins" AfterTargets="AddUmbracoFilesToOutput">
<ItemGroup>
<FilesForPackagingFromProject Remove=".\App_Plugins\UmbracoForms\Data\**\*.*"/>
</ItemGroup>
</Target>
Reference: https://our.umbraco.org/documentation/Getting-Started/Setup/Install/install-umbraco-with-nuget#post-installation

Related

How do I specify a target architecture when building projects in Visual Studio code?

I am new to VS code/F# and I am trying to build a F# console app (on both Windows workstation and on my Linux computer).
I installed the Ionide extension together with FAKE.
The code I am considering is the Iris example (see How to translate the intro ML.Net demo to F#?), creating a New F# Project with Ionide and using Microsoft.ML.
My iris.fsproj is
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<DebugType>portable</DebugType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="iris.fs" />
<None Include="App.config" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
When running the script (which I do with the "play" button aka F#: run script provided with VS Code/Ionide) I get:
C:\Users\MyUser\.nuget\packages\microsoft.ml\0.2.0\build\Microsoft.ML.targets(16,5): error : Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'.
together with
Running build failed.
Error:
System.Exception: dotnet build failed
How do I target x64 with the project structure provided by Ionide?
It should be as simple as adding the following line to your PropertyGroup section:
<PlatformTarget>x64</PlatformTarget>
There are more complicated setups possible using the Condition attribute to set the platform target based on various command-line arguments to the compiler, but that should be the simplest way to get you up and running.

Why won't my msbuild deploy work after I check "Precompile during publishing" on the publish properties?

I checked the middle option, below, "Precompile during publishing".
This changed the FDeploy.pubxml file by a few lines. Fine. I committed this single change to my build server.
Heres the pubxml:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Temp</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
</Project>
The remote build with mvcbuildviews enabled passed. The remote deploy failed with errors like:
Error 82 The name 'ViewBag' does not exist in the current context
Error 5 The name 'model' does not exist in the current context
and so on. There's over 100 errors like this. Keep in mind the regular msbuildviews enabled msbuild step worked fine with the same code.
I use msbuild on the web project csproj this way:
/p:DeployOnBuild=true /p:PublishProfile=FDeploy /p:VisualStudioVersion=12.0 /p:Configuration=Release
Any clues? Oh yeah, checking the box caused the same errors on my dev machine as well, I had to delete the bin, obj and appdata folders completely to neutralize it. However, doing a fresh checkout on the build server did not help.
Also note that when I went back to my old deploy profile it took a fresh checkout to fix the deploy.
I had to cheat to solve this problem: I restricted my use of MvcBuildViews to only the 'Debug' version of the project:
In the csproj file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>
I ran into other inexplicable errors using mvcbuildviews when deploying. Seems best to avoid using it altogether. Anyway, the build is still kept clean because I compile and test the debug version too.

Adding files to the bin directory at Build and Publish

I have two license files that I would like to include in my \bin directory both when I build and publish.
Both files are in the App_Data directory (their initial location doesn't matter, they just need to end up in the \bin) and have the following properties set:
Build Action = Content
Copy to Output Directory = Copy Always
They are in not the \bin when I build or publish.
What is wrong with my setup: the settings, the folders, the files, something else...?
UPDATE
I moved the files out of the App_Data directory and placed them in the project root and now they are copied to the \bin on build.
I've done this in a few projects by expanding my .csproject file slightly. The following code should be put directly beneath the Project node in your WebProject.csproj.
The AfterBuild target simply copies a set of files ("unreferenced DLLs" in this case) to the bin-folder when building normally from Visual Studio. The CustomCollectFiles basically do the same thing when deploying.
<PropertyGroup>
<UnreferencedDlls>..\lib\Unreferenced\**\*.dll</UnreferencedDlls>
</PropertyGroup>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="AfterBuild">
<Message Text="Copying unreferenced DLLs to bin" Importance="High" />
<CreateItem Include="$(UnreferencedDlls)">
<Output TaskParameter="Include" ItemName="_UnReferencedDLLs" />
</CreateItem>
<Copy SourceFiles="#(_UnReferencedDLLs)" DestinationFolder="bin\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="CustomCollectFiles">
<Message Text="Publishing unreferenced DLLs" Importance="High" />
<ItemGroup>
<_CustomFiles Include="$(UnreferencedDlls)" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
The part you need to modify is basically the UnreferencedDlls node to match your folder structure. The **\*.dll part simply means "every DLL file at any level beneath here".
If you're using Visual Studio:
Show your file properties (Click on your file or Right-click on it then choose Properties)
At the Copy to Output Directory property choose Copy always or Copy if newer.
At build time, the file is going to be copied at the bin directory: Debug or Release...
not necessarily a direct answer, but I highly suggest not using the baked in "publish" mechanism, but rather wire up a build script (probably in powershell) that will do everything you need. It's really easy to hook into MSBuild as well as nUnit and also copy files and move them around.
POWERSHELL (rough) example.
# Get Directory Location
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
# Build the application using MSBuild
cmd /c C:\Windows\Microsoft.NET\Framework\$v4_net_version\msbuild.exe "$directorypath\MyProject.sln" /p:Configuration=Release
# Run the tests using nUnit
cmd /c $directorypath\build\nunit\nunit-console.exe $solutionPath\MyProject.Tests\bin\debug\MyProject.Tests.dll
# Copy the license to the appropriate directory
Copy-Item -LiteralPath "$directorypath\mylicensefile.txt" "$directorypath\bin\release" -Force
# NOTE: You are going to have to adjust this to match your solution and projects.
In this post on Microsoft Connect the answer is much simpler:
Referenced assemblies in Unit Test are not copied in TestResults/Out
So what I did was the following:
[TestClass]
[DeploymentItem("Some.dll")]
public class SomeTests
{
...
}
It works fine for me.
Hope it help.

Liferay ant deploy failure

I have been having trouble deploying liferay portlets and themes from the command line with ant deploy;
sample execution:
pwd: C:\liferay-plugins-sdk\themes
create.bat deep-blue "Deep Blue"
cd deep-blue-theme
ant deploy
-> Buildfile: C:\liferay-plugins-sdk\themes\deep-blue-theme\build.xml
-> compile:
-> BUILD FAILED
-> C:\liferay-plugins-stk\themes\build-common-theme.xml:172: C:\liferay-plugins-sdk\themes\deep-blue-theme\liferay-portal-6.0.6 omcat-6.0.29webappsROOT\html\themes_unstyled does not exist.
the problem appears to be with the bold section and how the path is obviously incorrect; where is this directory being set?
edit:
the problem was my app.server.dir in build.{username}.properties
The error is a result of the ant build not being able to find a Liferay installation (which contains items needed by the SDK).
By default, the build properties in the SDK are set up on the assumption that your setup looks like this:
- Your Development Directory
- bundles
- data
- deploy
- license
- tomcat-6.0.29
- liferay-plugins-sdk
Where bundles contains a Liferay bundle distribution, including the bundled Tomcat server.
You can see this setup in the build.properties file at the root level of your SDK.
#
# Specify the paths to an unzipped Tomcat bundle.
#
app.server.type=tomcat
app.server.dir=${project.dir}/../bundles/tomcat-6.0.29
app.server.deploy.dir=${app.server.dir}/webapps
app.server.lib.global.dir=${app.server.dir}/lib/ext
app.server.portal.dir=${app.server.dir}/webapps/ROOT
The recommended way to change this is not to edit this section of build.properties, but to create overriding entries in a new file, called build.username.properties. (where username is your user name on your computer account).
As you say in the comment to kirkz's answer, you have already set your build.connor.properties: You obviously have used backslash in there. Here \t is short for the tab character. This explains what you see: ...liferay-portal-6.0.6 omcat... (there's a tab between 6.0.6 and omcat)
Do only use forward-slash in properties files (when you refer to file names, no matter if you're on windows or on any other platforms)
I think to solve this issue just for now. To check weather you are getting unsuccessful build or not you can try this solution:
I have just used the static liferay path in this solution.
<elseif>
<equals arg1="${theme.parent}" arg2="classic" />
<then>
<copy todir="docroot" overwrite="true">
<fileset
dir="C:/Liferay/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT/html/themes/classic"
excludes="_diffs/**,templates/**"
/>
</copy>
<copy todir="docroot/templates" overwrite="true">
<fileset
dir="C:/Liferay/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT/html/themes/classic/templates"
includes="*.${theme.type}"
/>
</copy>
</then>
</elseif>
After setting up this code in your build-common-theme.xml file you will NOT get omcat-6.0.29webappsROOT\html\themes_unstyled error at least.

Using VS 2008 Web Deployment Projects with ASP.NET MVC

Has anyone got a Web Deployment Project to work with ASP.NET MVC? When I open the "deployed" project, a lot of the files are missing that MVC requires and makes it tough to Publish to the server with all the missing files in the project.
Or... Is there a better way than a Web Deployment Project to modify the Web.Config for MVC apps? I have differences (SMTP and connection strings) that need to be updated before uploading and Web Deployment Projects seem to be the right method.
Thanks as always!
Update: I am missing at least global.asax, global.asax.cs, and default.aspx.cs.
Update 2: Once I Publish, I get this error. Could not load type 'AppNamespace._Default'.
I haven't set up a Deployment project yet with my mvc app but I've been using this technique outlined by Scott Hanselman and it works great.
Managing Multiple Configuration File Environments
The 3 specific files you have listed are all compiled into the binary produced by your ASP.NET MVC web project. Open up your .csproj and you will see:
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
Open up your binary in a tool such as Reflector and you will see the classes. Therefore you don't need to deploy them.
These MSBuild steps in the MVC .csproj render part of what the Web Deployment Project does (i.e. compiling a single binary for the site) redundant.
As for the token replacement you can either keep your Deployment project or probably copy the relevant MSBuilds steps from your .wdproj file into your .csproj file. This is not something I've done, but am shortly to try myself.
I've found it working for me.
When you say there are files missing, are you talking about the System.Web.Mvc files and such? You need to make sure in your web application that these references are set to copy locally.
I have deployt succesfully to IIS6 using a Web Deployment Project.
I had issues deploying to Server 2003 first, but in my case it realy was a problem of the stage-environment.
I first deployt to a local IIS to check if it was a problem of the build or of the environment.
I did not use config - replacement.
This is my build script:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe "D:\Projekte\NiceProjectName\source\NiceProjectName_Build\NiceProjectName_Build.wdproj" /t:Build /p:Configuration=Release
Here is my wdp:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E5E14CEB-0BCD-4203-9A5A-34ABA9C717EA}</ProjectGuid>
<SourceWebPhysicalPath>..\NiceProjectName</SourceWebPhysicalPath>
<SourceWebProject>{3E632DB6-6DB3-4BD0-8CCA-12DE67165B48}|NiceProjectName\NiceProjectName.csproj</SourceWebProject>
<SourceWebVirtualPath>/NiceProjectName.csproj</SourceWebVirtualPath>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>.\Debug</OutputPath>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>NiceProjectName_Build</SingleAssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<OutputPath>..\..\deploy</OutputPath>
<EnableUpdateable>false</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>NiceProjectName</SingleAssemblyName>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets" />
</Project>

Resources