I've got a Web API 2 project set up using Code First. The publish dialog was detecting the DB and allowing me to use Code First Migrations.
I then added a second DB connection using the steps here.
Now when I publish, the dialog only detects the new database and does not give me any options for the original one.
I removed every reference to the second DB that I can find, but the Publish dialog is still showing references to it (and not to the original DB). I've compared my current revision to the one before I added the second DB, and the pubxml for my publishing profile is different, but VS auto-generates the part that is different:
Before:
<PublishDatabaseSettings>
<Objects>
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="True">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Project.Models.ApplicationDbContext, Project" MigrationConfiguration="Project.Migrations.Configuration, Project" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
...
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String">
<ParameterValue>Data Source=localhost;Initial Catalog=OriginalDB;User ID=user;Password=password</ParameterValue>
</MSDeployParameterValue>
</ItemGroup>
<ItemGroup>
<_ConnectionStringsToInsert Include="DefaultConnection" />
</ItemGroup>
After:
<PublishDatabaseSettings>
<Objects>
<ObjectGroup Name="NewDatabase" Order="2" Enabled="False" xmlns="">
<Destination Path="" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=newcatalog;Integrated Security=True;Application Name=EntityFramework" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\NewDatabase_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="data source=(localdb)\MSSQLLocalDB;initial catalog=newcatalog;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
...
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)NewDatabase-Web.config Connection String" />
</ItemGroup>
I'm not sure where this is being generated from, how would I go about getting this to work with both databases, or failing that, getting it back to the point where it works with the original DB?
Related
I have a website hosted on IIS 10. The website has a feature to write files in a folder. I have given write permission to IIS_IUSER, IUSER and USER groups on the wwwroot folder.However, I still see access denied exception.
One workaround I do is allowing write permission to AppPoolIdentity user (the user with name name as my application name) on the website folder. However, this permission gets removed each time I do a web deploy.
Is there something I am missing? I have windows server 2016.
If you use Web Deploy from Visual Studio, the publish will overwrite the ACLs on the server by clearing them to the inherited defaults of the parent.
To avoid update ACL each time when you publish your web application.
You could add below command in your PublishProfiles's pubxml.
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
Details publish profile as below:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>http://localhost:9825/</MSDeployServiceURL>
<DeployIisAppPath>WebFormApplication</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
<EnableMSDeployBackup>False</EnableMSDeployBackup>
<UserName />
<_SavePWD>False</_SavePWD>
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="WebFromIdentityTest.Models.ApplicationDbContext, WebFromIdentityTest" Origin="Configuration" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
</ItemGroup>
</Project>
I'm trying to get my JS and CSS files to be automatically minified when publishing our Web App, but it only seems to work on a File System publish not a web deploy; using the target CopyAllFilesToSingleFolderForPackage in a .pubxml file.
I've tried running on different targets but the same result.
<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\lib\AjaxMinTask.dll" />
<Target Name="CompressJsAndCss" AfterTargets="CopyAllFilesToSingleFolderForPackage">
<ItemGroup>
<JS Include="$(_PackageTempDir)\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js" />
<CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<Message Text="Compressing JavaScript and CSS files in $(PublishDir)..." Importance="high" />
<AjaxMin JsKnownGlobalNames="jQuery,$" JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
</Target>
I'd expect it to minify the files in the temporary package folder, but nothing happens.
So I've managed to solve the problem.
I had to find the right target and folders to do this on:
<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\lib\AjaxMinTask.dll" />
<Target Name="CompressJsAndCss" AfterTargets="CopyAllFilesToSingleFolderForAspNetCompileMerge">
<ItemGroup>
<JS Include="$(IntermediateOutputPath)\AspnetCompileMerge\Source\**\*.js" Exclude="$(IntermediateOutputPath)\AspnetCompileMerge\Source\**\*.min.js" />
<CSS Include="$(IntermediateOutputPath)\AspnetCompileMerge\Source\**\*.css" Exclude="$(IntermediateOutputPath)\AspnetCompileMerge\Source\**\*.min.css" />
</ItemGroup>
<Message Text="Compressing JavaScript and CSS files in $(IntermediateOutputPath)..." Importance="high" />
<AjaxMin JsKnownGlobalNames="jQuery,$" JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
</Target>
Now after the first copy, it will minify the files and use those going forward
I have a target in my .csproj file which Looks like this:
<UsingTask TaskName="GetPackageVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<FileName ParameterType="System.String" Required="true" />
<PackageVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Using Namespace="System.IO" />
<Using Namespace="System.Xml.Linq" />
<Code Type="Fragment" Language="cs"><![CDATA[
var doc = XDocument.Load(FileName);
var defaultNamespace = doc.Root.GetDefaultNamespace();
PackageVersion = doc.Root.Element(defaultNamespace.GetName("Identity")).Attribute("Version").Value;
]]>
</Code>
</Task>
</UsingTask>
<Target Name="GetZip">
<GetPackageVersion Filename="Package.appxmanifest">
<Output PropertyName="PackageVersion" TaskParameter="PackageVersion" />
</GetPackageVersion>
<ItemGroup>
<BinDirectoryFiles Include="$(MSBuildProjectDirectory)\AppPackages\MyApp_$(PackageVersion)_x86_MyApp_Test\**\*.*" />
</ItemGroup>
<Zip Files="#(BinDirectoryFiles)" WorkingDirectory="$(MSBuildProjectDirectory)\AppPackages\MyApp_$(PackageVersion)_x86_MyApp_Test" ZipFileName="$(MSBuildProjectDirectory)\Zip\MyApp_$(PackageVersion).zip" />
</Target>
My project is on GitLab and builds automatically when I commit something.
The project builds without any problems and than it should zip the apppackages. At the beginning it worked, but after installing the newest Windows 10 Version (1803) on my virtual machine it fails at the Zip target with this error:
C:\Multi-Runner\builds\9fca3796\0\mobile\mail-windows\MyApp\MyApp.csproj(657,5): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin\Microsoft.Build.Tasks.Core.dll". A required privilege is not held by the Client
I don't know why it comes up now. I don't changed anything. I have to say that if I call the target from a command prompt on my VM than it works.
In the latest version of Windows 10 the default build location C:\gitlab-runner\builds is protected. One solution is to move the builds directory into the runner user's home folder by adding a builds_dir line to the runners section of your config.toml file. The escaped backslashes were required to parse the path in the .toml correctly.
builds_dir = "c:\\Users\\gitlab-ci-users\\builds"
I had to restart my gitlab service in order for this change to take effect.
I've hit something similar, but not on my machine (at another team). Switching from CodeTaskFactory into RoslyCodeTaskFactory fixed it for us (but it won't build with MSBuild < 15.8)
https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-roslyncodetaskfactory?view=vs-2019
I have a major trouble with my application.
I have an application angular 2. I packaged this app with Cordova. And then with visual studio, I have built a windows application.
In my app I use WebSocket, my app uses WebSockets to send a message to a local server WS. This server is running in local through a windows service.
My problem is that I can't connect my app with the WS server. In the on error event, I don't have anything.
If I build my app on my computer and install it in this same computer it works, but if I install this app in another computer or tablet it doesn't work.
All devices are on windows 10.
Here are my config.xml from my cordova project
<?xml version="1.0" encoding="utf-8"?>
<widget defaultlocale="fr-FR" id="toto" version="1.0.0" windows-packageVersion="1.0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
<content src="index.html" />
<access origin="*" />
<vs:features />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="10.0" />
<preference name="windows-phone-target-version" value="10.0" />
<preference name="WindowsDefaultUriPrefix" value="ms-appx://" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="wp8">
<splash height="1280" src="res/screens/wp8/SplashScreenImage.png" width="768" />
</platform>
<plugin name="cordova-windows-capability-localnetwork" src="https://github.com/dilhan2013/cordova-windows-capability-localnetwork.git" version="0.1.0" />
<vs:platformSpecificValues>
<vs:platformSpecificWidget platformName="windows">
</vs:platformSpecificWidget>
</vs:platformSpecificValues>
<preference name="DisallowOverscroll" value="true" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
<plugin name="cordova-plugin-console" version="1.0.7" />
</widget>
Thank you for your help.
Sorry in advance for my English
The problem in this particular situation comes from the fact that the app is trying to reach the Web Socket running on localhost.
Like it is mentioned as an answer to this post : Cannot connect to localhost in windows store application, developed windows store app can be isolated from loopback for security reasons.
The solution consists first in finding the installed app PackageFamilyName (this can also be done with the SID from regedit, like in the post mentioned above). For this, run this Power Shell command:
Get-AppxPackage | ? { $_.Name -like 'APP_NAME' }
APP_NAME can be part of the name you know your app has.
Once the description of the package is displayed, add the app to the NetIsolation exemption list by entering the PackageFamilyName in the following Power Shell command:
CheckNetIsolation LoopbackExempt -a -n="PackageFamilyName"
The app should now be part of the exemption list displayed with:
CheckNetIsolation LoopbackExempt -s
And it should be allowed to access the localhost.
Check your WS server, does it accept incoming requests from hosts other than localhost?
I'm using TFS in Visual Studio 2013 & SSDT to create various SQL Database scripts. i.e. I'm doing all my SQL DB development via VS not SSMS.
Want I'm now trying to achieve is to generate/retreive a version number from an external text file when the project is built/published, based on the functionality posted here:
http://www.codeproject.com/Articles/468855/Working-with-MSBuild-Part-2
So I've added the following to the MyProject.sqlproj xml file:
<PropertyGroup>
<WorkingFolder>C:\Source Control\MISTP\Main\DB\SSMS\MyProject</WorkingFolder>
</PropertyGroup>
<Target Name="GetVersion">
<Message Text="GetVersion: Reading version number from VersionInfo.txt" />
<Attrib Files="$(WorkingFolder)\VersionInfo.txt" Normal="true" />
<Version VersionFile="$(WorkingFolder)\Build\VersionInfo.txt">
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
<Message Text="GetVersion: $(Major).$(Minor).$(Build).$(Revision)" />
</Target>
<Target Name="SetVersion" DependsOnTargets="GetVersion">
<Message Text="SetVersionInfo: Updating Versions in all files" />
<CreateItem Include="$(WorkingFolder)\**\*.*">
<Output TaskParameter="Include" ItemName="Files"/>
</CreateItem>
<Attrib Files="#(Files)" Normal="true" />
<FileUpdate Files="#(Files)" Regex="FileVersionAttribute\("(\d+)\.(\d+)\.(\d+)\.(\d+)"\)" ReplacementText="FileVersionAttribute("$(Major).$(Minor).$(Build).$(Revision)")" />
<FileUpdate Files="#(Files)" Regex="FileVersion\("(\d+)\.(\d+)\.(\d+)\.(\d+)"\)" ReplacementText=" FileVersion ("$(Major).$(Minor).$(Build).$(Revision)")" />
<FileUpdate Files="#(Files)" Regex="FileVersion\("(\d+)\.(\d+)\.(\d+)\.(\d+)"\)" ReplacementText="FileVersion("$(Major).$(Minor).$(Build).$(Revision)")" />
</Target>
I have a VersionInfo.txt file located in:
C:\Source Control\MISTP\Main\DB\SSMS\MyProject\Build
Which simply contains the string: 1.2.3.4
However, this doesn't seem to actually do anything when I Build and/or Publish the project within VS. What am I missing?!
I'm new to MSBuild, but the syntax appears correct - and is largely lifted from the codeproject article - and the path to the file are ok.
It feels like the xml is not being executed, but I'm assuming that it's very presence in the .sqlproj file will result in it being executed.
Thanks
The target isn't triggered during the build. Update "SetVersion" target as following:
<Target Name="SetVersion" DependsOnTargets="GetVersion" AfterTargets="PostBuildEvent">